• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 859
  • Last Modified:

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.
1 Solution
Use the BeforeColUpdate-Event instead of the AfterColEdit.
There you'll have the cancel flag that you are looking for


Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now