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.
error trap on P Key duplicate vb6
Name: Anthony Arde Date: May 16, 2005 at 03:19:09 Pacific OS: winxp pro sp2 CPU/Ram: 386mb ram p3 733
Comment:
i get an error that bombs my program out when ever a duplicate value is entered in my DB program, please can someone tell me how to trap this error and let the user know what happened, thanks ant
Name: StuartS Date: May 16, 2005 at 04:25:04 Pacific
Reply:
at the beginning of the module put:
On Error Goto Duplicate:
Your stuff here
ExitSub:
Exit Sub
Duplicate: if err = 3022 then MssBox"Duplicate Record",vbOK end if Resume ExitSub:
You need to single step through the code and discover exactly which error is being generated and then allow for it. Error 3022 applies to DAO but may not apply if you are using ADO or MySQl.
ExitSub: and Duplicate: are just labels and can be anything you want. Notice the trailing colon.
Of course the other solution is to configure your database so it accepts duplicate records but they may or may not be what you want.
Summary: Haven't used VB in over a year but I think it's just simple error trapping Private Sub SomeRoutine On error goto errtrap 'write your code here Exit Sub errtrap: Msgbox Err.Description End Sub Jimbo...
Summary: G'day, Well, I've had a lie down now and I feel much better. I had a quick look at your code and made these changes. I didn't change this, but one word of warning: try to keep away from reserved words...
Summary: What you are looking for is validation of input. There are a number of ways to do this. Here is an example. This program checks each character input to see if it a number or a decimal point. Input end...