VB6 Data access error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Wernerh
    New Member
    • Jul 2007
    • 104

    VB6 Data access error

    Please could someone help with this problem. I have a datagrid that works perfectly back to a MS database. I have written the keycode functions for up, down, left and right keys in the datagrid. A error occurs when you use the up arrow key to the first record in the database. If you are on the first record and press the up key then you get the data access error as there is obviously no record. How can I stop the keycode from firing when it reaches the first record.

    VB Code:

    If KeyCode = vbKeyRight Then
    KeyCode = vbKeyReturn And vbKeyTab
    End If
    If KeyCode = vbKeyDown Then
    Adodc2.Recordse t.MoveNext
    End If
    If KeyCode = vbKeyDown Then
    KeyCode = vbKeyTab And vbKeyLeft
    End If

    If KeyCode = vbKeyUp Then
    Adodc2.Recordse t.MovePrevious
    End If

    If KeyCode = vbKeyUp Then
    KeyCode = vbKeyTab And vbKeyLeft
    End If

    If KeyCode = vbKeyDelete Then
    KeyCode = vbKeyBack And vbKeyReturn
    End If

    Thanks
    Werner
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    You need to check the BOF and EOF of the recordset.

    There are templates in VB6.0 for this . Just check there.

    Comment

    Working...