If statement not working

Workaholic

Registered User.
Local time
Today, 10:16
Joined
Jun 20, 2004
Messages
17
Private Sub cmdFeedSub_Click()

If IsNull(txtfirstname) Or IsNull(txtsecondname) Or IsNull(txtteam) Or IsNull(txtRegion) Or IsNull(txtsupport_id) Then
Me.lblRed1.Visible = True
Cancel = True

Else
Me.lblGreen.Visible = True
DoCmd.RunCommand acCmdSaveRecord

End If


Can anyone tell me why this statement won't go by the first part.

Cheers
 
What error message are you receiving?
 
If IsNull(me!txtfirstname)


???
ken
 
No matter if the conditions are met or not it still only executes the first part.
 
So there is no error message but the criteria fails to work. I can't see why this is the case
 
are you sure that the fieldnames are all spelled correctly ?
 
There aren't enough brackets around all the Or conditions, it's much easier to have them as separate statements.

I didn't think Cancel=True was available for command buttons either?
 
No, although I prefer the dot to the bang I think the statement should look more like

If ( IsNull(txtfirstname) Or IsNull(txtsecondname) Or IsNull(txtteam) Or IsNull(txtRegion) Or IsNull(txtsupport_id)) Then
 
Rich said:
No, although I prefer the dot to the bang I think the statement should look more like

If ( IsNull(txtfirstname) Or IsNull(txtsecondname) Or IsNull(txtteam) Or IsNull(txtRegion) Or IsNull(txtsupport_id)) Then

But where is the me. in IsNull(txtfirstname)? Do you not need it?

ken
 
Remove Cancel = True - it shouldn't, as Rich says, be there.

You can replace it with Me.Undo
 

Users who are viewing this thread

Back
Top Bottom