By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,255 Members | 2,773 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,255 IT Pros & Developers. It's quick & easy.

VB6 Data access error

100+
P: 104
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
May 6 '08 #1
Share this Question
Share on Google+
1 Reply


debasisdas
Expert 5K+
P: 8,127
You need to check the BOF and EOF of the recordset.

There are templates in VB6.0 for this . Just check there.
May 6 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.