Connecting Tech Pros Worldwide Forums | Help | Site Map

VB6 Data access error

Member
 
Join Date: Jul 2007
Posts: 104
#1: May 6 '08
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.Recordset.MoveNext
End If
If KeyCode = vbKeyDown Then
KeyCode = vbKeyTab And vbKeyLeft
End If

If KeyCode = vbKeyUp Then
Adodc2.Recordset.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's Avatar
Moderator
 
Join Date: Dec 2006
Location: Bangalore ,India
Posts: 7,508
#2: May 6 '08

re: VB6 Data access error


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

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


Similar Visual Basic 4 / 5 / 6 bytes