I have a form I am trying to not go to a new record until certain fields have data entered by user. I have the following code, but whenever I use Access's New Button (at bottom of form), it will still go to a new record without data entry in the desired fields. These fields can not be required in the bable because it's based on a selection.
Example If user selects "House", only certain fields need to be entered, if user selects "Condo" only certain fields need to be entered. This is just an example. Below is the actual code I have so far. ----Thanks to all who can help me!!!
Private Sub Form_AfterUpdate()
Dim strUserInput
If Me.Contract_Type = "House" Then
If IsNull(Me.ITB_No) Then
strUserInput = InputBox("Please enter ITB number")
'Check to see if there is any entry made to input box, or if
'cancel button is pressed. If no entry made then exit sub.
If strUserInput = "" Or strUserInput = Empty Then
MsgBox "No Input Provided", vbInformation, "Data Required!"
DoCmd.GoToControl "ITB_No"
Exit Sub
End If
'If input entered, continue
'If input not entered, give message and exit sub
If strUserInput Is Not Null Then
Me.ITB_No = strUserInput
Else
MsgBox "You MUST enter a number", _
vbOKOnly, "Important Information!"
Exit Sub
End If
End If
End If
End Sub
Example If user selects "House", only certain fields need to be entered, if user selects "Condo" only certain fields need to be entered. This is just an example. Below is the actual code I have so far. ----Thanks to all who can help me!!!
Private Sub Form_AfterUpdate()
Dim strUserInput
If Me.Contract_Type = "House" Then
If IsNull(Me.ITB_No) Then
strUserInput = InputBox("Please enter ITB number")
'Check to see if there is any entry made to input box, or if
'cancel button is pressed. If no entry made then exit sub.
If strUserInput = "" Or strUserInput = Empty Then
MsgBox "No Input Provided", vbInformation, "Data Required!"
DoCmd.GoToControl "ITB_No"
Exit Sub
End If
'If input entered, continue
'If input not entered, give message and exit sub
If strUserInput Is Not Null Then
Me.ITB_No = strUserInput
Else
MsgBox "You MUST enter a number", _
vbOKOnly, "Important Information!"
Exit Sub
End If
End If
End If
End Sub