Syntax Help Please

C

cvegas

I am trying to get a message box to pull up if a user has not selected a item
in Frame303. I have tried what you see below and also to check for nulls. I
can't get this to work. Any help with syntax would be appreciated.

whichway = Me.Frame303

If whichway <> 1 Or whichway <> 2 Or whichway <> 3 Then
MsgBox "Please Select if this is One Way or Round Trip"
Cancel = True
End If

'================================== START TL ORDER TO CONVENTION CENTER
======================================'

If whichway = 1 Then 'Insert an LTL Order into Shipment Table
 
A

Allen Browne

Null is not equal to (or different from) anything, so use IsNull() to test
for Null.

This example shows how to prevent the record being saved if nothing was
selected in Frame303.

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.Frame303) Then
Cancel = True
MsgBox "Select whichway."
Me.Frame303.SetFocus
End If
End Sub

For an even simpler solution, open your table in design view, and set the
Required property of the field to Yes.

For more info on handling nulls, see:
Common errors with Null
at:
http://allenbrowne.com/casu-12.html
 
D

Dennis

Assuming from your code, Frame303 contains three radio buttons or check boxes
where only one can be selected, but none are selected to start with

If IsNull(Frame303) then
MsgBox "Please Select if this is One Way or Round Trip"
else
Msgbox Frame303.Value & " has been selected"
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

Top