BeforeUpdate

G

Guest

How can I add to the current code (below) a test to make sure that if
Location 1 field is not 0 or is not null and Location 1 RorM field is null
that a msgbox appears stating that "Location 1 RorM must be completed."? I've
tried the following, but it doesn't work. Any ideas how I can add it to the
BeforeUpdate code that is already being used? Thanks.

I've tried:
If me.Location_1 = 0 or IsNotNull(me.Location_1) And Location 1_RorM = ""
then msgbox ("You must pick R or M")
Exit Sub
End If

Current Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Nz(Me!Welded_By_Robot, 0) = 0 Then
Cancel = True 'Don't let the record be saved
Dim strMsg As String 'To assign the message's text
strMsg = "You must choose Yes or No"
If MsgBox(strMsg, vbOKCancel + vbExclamation, _
"Incomplete Data") = vbCancel Then 'If user response is
"Cancel"
Me.Undo

End If
End If
End Sub
 
M

Marshall Barton

See below.
--
Marsh
MVP [MS Access]

How can I add to the current code (below) a test to make sure that if
Location 1 field is not 0 or is not null and Location 1 RorM field is null
that a msgbox appears stating that "Location 1 RorM must be completed."? I've
tried the following, but it doesn't work. Any ideas how I can add it to the
BeforeUpdate code that is already being used? Thanks.

I've tried:
If me.Location_1 = 0 or IsNotNull(me.Location_1) And Location 1_RorM = ""
then msgbox ("You must pick R or M")
Exit Sub
End If

Current Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Nz(Me!Welded_By_Robot, 0) = 0 Then
Cancel = True 'Don't let the record be saved
Dim strMsg As String 'To assign the message's text
strMsg = "You must choose Yes or No"
If MsgBox(strMsg, vbOKCancel + vbExclamation, _
"Incomplete Data") = vbCancel Then 'If user response is
"Cancel"
Me.Undo

End If
End If

If me.Location_1 = 0 AND Not IsNull(me.Location_1) _
And IsNull(Location 1_RorM) _
then msgbox ("You must pick R or M")
Cancel = True
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top