Computing.Net > Forums > Programming > VB6 and Access 2000

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

VB6 and Access 2000

Reply to Message Icon

Name: Mark Long
Date: April 2, 2004 at 17:31:32 Pacific
OS: Win 98
CPU/Ram: 300/512
Comment:

I have created a project (Reference Library) using VB6 and Access 2000. The VB front end consists of two forms, Title Form and Copy Form. The following code is run at ‘Form Activate’ and is situated on the Title Form.
The problem I am having is as a complete novice I am unsure of the code I have begged from exercises I have done on evening classes. The majority of the code is working for the functions

Problem: I go to the Copy form to delete a copy from the database which works fine. I then go back to the Title Form but am faced with an error code and ‘Record is Deleted’ this is because the line below:

If DatCopy.Recordset.Fields("ISBN") = TxtISBN.Text Then

Is activated with the form (the code counts No of Copies and displays to form).

Is there an ‘Else’ or a line of code that will stop this error occurring. I need for the Title form to realise that the copy no longer exists and update accordingly.

Also anybody know if there is a way to reset an access database as I have added and removed that may records that my first record is now numbered something like 24.

Regards

M

DatCopy.Recordset.MoveFirst

' WHile not at the end of the Copy table
While Not DatCopy.Recordset.EOF

' If the ISBN in the DatCopy table matches the one in the Text Box
If DatCopy.Recordset.Fields("ISBN") = TxtISBN.Text Then

' Add 1 to the number of copies
numOfCopies = numOfCopies + 1


End If

' Move to the next record in the Copy table
DatCopy.Recordset.MoveNext

Wend



Sponsored Link
Ads by Google

Response Number 1
Name: StuartS
Date: April 2, 2004 at 18:41:24 Pacific
Reply:

You don't show it, but somewhere in your code you are deleting a record. When you delete a record the record pointer does not move, it remains pointing at a non-existing record.

Its best to refresh the recordset whenever you delete a record. DataCopy.Refresh will do it.

Be careful with move Movefirst and Movelast. If the record deleted was the first first or last record respectively, they will produce an error.

It may be that there is no way you can prevent the error form occurring. Without seeing all the code it is impossible to tell. If this is the case you may have to implement an error trap using VBs error handling facilities.


Stuart


0
Reply to Message Icon

Related Posts

See More


security : OOP vs Proced... C++ 2 dimensional char ar...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: VB6 and Access 2000

VB6 & Access 2000 Record Problem www.computing.net/answers/programming/vb6-amp-access-2000-record-problem/9154.html

Access 2000 Date/Time help www.computing.net/answers/programming/access-2000-datetime-help/2783.html

programming in access 2000 www.computing.net/answers/programming/programming-in-access-2000/8631.html