Switching Between Forms

  • Thread starter Thread starter bill.
  • Start date Start date
B

bill.

I am using a command button to switch between forms. I am
having a problem with setting up the error messages when
data is missing . When I click on the button, it switches
to the new form and then displays the error message. I
don't want the second form to open unless all the data is
entered in the first form. When I placed the error message
after the Err_Command()_Click, it doesn't recognize it. I
placed the error messages also directly after the On Error
Goto Err_Command()_Click. The code that opens the second
form is after the error messages in the On Error Goto
Err_Command()_Click and looks like this:

Dim stDocName as String
Dim stLinkCriteria As String

stDocName = 'frmExtraSpools"
DoCmd.OPenForm stDocName, , , stLinkCriteria

I have an add button, and it displays the error messages
correctly. What can I do so that the second form doesn't
open unless all information in the first form is filled in?
 
I put my data validations before my OpenForm statement:

If IsNull([Field1]) or [Field1] = "" Then
MsgBox "ErrorMessageHere"
Field1.SetFocus
End If

' (and so on through all the appropriate controls)

' (then:)

DoCmd.OpenForm ...

Hope this helps!

Howard Brody
 
Back
Top