Prompt for null values

  • Thread starter Thread starter Nick
  • Start date Start date
N

Nick

I have written a piece of code that prompts users to enter values in text
fields or combo boxes before they can proceed. The code for one of the
fields is listed below:

Private Sub Part__Exit(Cancel As Integer)
If IsNull(Me.Part_) Then '<--small loop to prompt for null values
MsgBox "Please Enter Part #! You Cannot Proceed Otherwise"
Me.Part_.SetFocus
Cancel = True
End If
End Sub

The code works well; however, I would rather create a prompt when the users
reach the "Save and Print Record" button that informs the users that a field
is null and they must enter a value before they can proceed. I am having a
little trouble with the code logic. Any help here would be GREATLY
appreciated.

Thanks in advance,

Nick
 
You can code similar validation in the "Save & Print" CommandButton_Click
Event Procedure:

Something like:

****Untested air-code****
Private Sub cmdSavePrint_Click()

If IsNull(Me.Part_) Then
MsgBox "Please Enter Part #! You Cannot Proceed Otherwise"
Me.Part_.SetFocus
Else
'Save Record ...
'Print ..
End If

End Sub
****Code ends****
 
Van, thanks for the help!

Nick C.

Van T. Dinh said:
You can code similar validation in the "Save & Print" CommandButton_Click
Event Procedure:

Something like:

****Untested air-code****
Private Sub cmdSavePrint_Click()

If IsNull(Me.Part_) Then
MsgBox "Please Enter Part #! You Cannot Proceed Otherwise"
Me.Part_.SetFocus
Else
'Save Record ...
'Print ..
End If

End Sub
****Code ends****

--
HTH
Van T. Dinh
MVP (Access)



having
 
Back
Top