1. In your error handler change 'if error =' to 'if err.number ='.
2. If that doesn't work put the code into its own procedure and call that procedure from the form activate event. Form loads and form activates can sometimes act funny. Thanks and Good Luck!
To create a stored procedure select tools-add procedure... from the vb menu. Enter a name and select Sub and Private. Then cut and paste everything from the 'On error..' statement to the last 'end if' before the end sub line. Paste it between the two lines of your new stored procedure. Last step go back to the form activate and type in the name of the new procedure you just created. It should be the onlt line that you see.
You should end up with something like you see below.
Private Sub Form_Activate()
ClassNumber
End Sub
Private Sub ClassNumber()
On Error GoTo ErrorHandler
ContinueHere:
prompt$ = "Please enter class number."
If you only need the code to kick-in when the form loads, then you could also do this:
Public Sub DisplayForm()
me.Show
DoEvents
'Form should be activated now
'Place your code from above here
End Sub
Place the above proceedure somewhere in the Form's code module.
Remove the code from the Form_Activate
When you open your form form the menu or where ever, do not call the load method:
Load Form1
But, instead call the newly created proceedure:
Form1.DisplayForm [/b][/i][/u]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
Zemp I did exactly what you said and after running it it didn't give me an error, but it also did pop the prompt back up to get the correct information.
So if I understand you did not get an error and the program went back to the 'continuehere:' label.
Then everything is working fine.
One more thing, when I copied your procedure into my last post I forgot to change your error handler. I hope you caught and corrected that. Your error handler should be
ErrorHandler:
If Err.Number = 3421 Then
MsgBox "Please check", vbCritical
Resume ContinueHere
End If
Thanks and Good Luck!
Well when the form loads it pops up with a prompt that asks the user for information. If they enter txt istead of numbers then they get the error 3421. Yes you did solve that but the dialog box closes and I need it to open up again to give the user another chance to enter the numbers.
What I meant to say was that I do have a message box command but it is not reading it/ It doesn't get that far down the lines of command. So it seems I got something in the wrong place or I am missing something.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.