Nested "If/Then" stmt

RustyRick

Registered User.
Local time
Yesterday, 16:11
Joined
Jan 31, 2013
Messages
123
I have 3 conditions that must be met on a form before a record should be saved. I have a "Yes/No" field in a bound button.

Condition

1) must equal 24.
2) can't exceed 14
3) can't exceed 100.

Then if it's a "Yes" ( it needs to input a "yes" in the control or field), and then "open a new record".

If "No" it needs to input a "No" in the control or field), and then "open a new record".

How and where do I focus that code? On the forms I'm thinking?
 
?? Don't understand what you are asking.

What must = 24?
What can't exceed 14?, can't exceed 100?
 
How do I write the code to do an "If/Then - Else" statement.

I have 3 calculations in un-bound boxes.

All three have to be correct for the record to be deemed "correct".

1) = 24
2) can't exceed 14
3) can't exceed 100

If there is any "false or no" then don't check the check box with a "True"

If all 3 are "True" then check the check box "True".

I hope this is clearer.
 
Thank you from the beginning. This will go along way to ensuring accurate data entry.

This is my code. Did you mean I need to put each series in a separate section?

Private Sub Form_BeforeUpdate(Cancel As Integer) (is this right?)
If [Day2] <> 24 Then
MsgBox "some error", vbOKOnly
Cancel = True
Exit Sub
End If
If [HOS] > 14 Then
MsgBox "some error", vbOKOnly
Cancel = True
Exit Sub
End If
If [AVGSpeed] > 100 Then
MsgBox "some error", vbOKOnly
Cancel = True
Exit Sub
End If
Me.RecOK = True

End Sub

I get a popup box that says "Some error" click OK and I get another Box that says "Can't go to the specified record".
 
What do you mean about the "Coded Tags". Thanks for the heads up[ about what "Me" refers to. I guess I should buy a book on VBA for dummies :-)

I'm going to try your advice now, but thanks ahead of time for your help!!
 

Users who are viewing this thread

Back
Top Bottom