DBGrid AfterColEdit

Hello Experts!

I'm working (VB5) with a bounded DBGrid and need to validate the information entered in Col# 7.

I've writted this code:

Private Sub DataGrid_AfterColEdit(ByVal ColIndex As Integer)
    If DataGrid.Col = 7 Then
    'Verify if CodeX is valid
        Set Db = Workspaces(0).OpenDatabase(App.Path & "\Data2.mdb")
        Set Rs = Db.OpenRecordset("Values")
        With Rs
            .Index = "CodeX"
            .Seek "=", DataGrid.Columns(7).Value
            If .NoMatch Then MsgBox "Invalid CodeX", 16, "Data2 Values"
        End With
    End If
End Sub

It works ok, but I want to return the focus to column 7 in order to force the entry of a valid CodeX.

What must I add?

Thanks in advance.
raulopezAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

richtsteigCommented:
Use the BeforeColUpdate-Event instead of the AfterColEdit.
There you'll have the cancel flag that you are looking for

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.