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

Updating Problem With Access Db And VB6

P: 12
Hi Guys

I have a VB6 form with the following fields
Identity Number

And i have a msaccess a DB1 table with a table called customers
In the db i have set the Identity Number as the primary key on my form i have a dbcontrol called data1 which is linked to the db and i have linked the three textboxes on the form to the field names. On the form i have three buttons called "New" , "Update" , "Delete". my code is as follows

New Button

Update Button

what happens is that when i enter duplicate data and enter the update button it gives me an error 524, which says, The changes you requested to the table were not successfull becuase they would create duplicate values in the index.
Which is great exactely what i want, but then the program terminates.

How do i get it to either update the db or tell the user a id number entered already exists and return to the form to allow the user to rectify the mistake or cancel it, sorry if this sounds like a really stupid question, but im stuck for an answer, any help will be appreciated

Aug 8 '07 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 10K+
P: 12,396
You have to trap the error and route the program. Something along the lines of:

Private Sub SomeControl_Click()
On Error Goto Error_Handler


Exit Sub

MsgBox Err.Description
Goto Exit_Here

End Sub
Aug 8 '07 #2

Post your reply

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