Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 2003: VBA IF statement with AND syntax 1

Status
Not open for further replies.

DajTwo

Technical User
Jul 17, 2008
157
US
Hi all

I have been requested to add conditional 'reminders' to users when data is entered in a form with a query rowsource. Most of them were simple but I am stuck with this one. I hope you can help me identifying the correct syntax or let me know of another possibility.

I have separated each occurrence to identify the bugs

I get errors in every statement :(

On Exit event

Private Sub audit_posted_date_Exit(Cancel As Integer)

'MsgBox to set the [audit_status] to "Posted" when the field is not null

If Me![audit_posted_date] Is Not Null And Me![audit_status] = "Pre-Posted" Then
MsgBox "Please make sure that the Audit Status is set to Posted", vbOKOnly, "Posted Date Verification"

End If

'MsgBox when the field is null AND the [audit_status] = "Pre-Closed' or "Closed"

If Me![audit_posted_date] Is Null And Me![audit_status] = "Pre-Closed" or me![audit_status] = “Closed Then
MsgBox "A Pre-Closed and Closed audit status requires a date in the Posted Date field", vbOKOnly, "Posted Date Verification"

'Ignore when the field is null AND the [audit_status] = "Pre-Posted"

'Ignore when the field is not null AND the [audit_status] is "Posted"


Thanks!!

If I did not say it before, I really appreciate the time and expertise of the users on this forum.
 

How about...
Code:
If Me![audit_posted_date] Is Null And [b][COLOR=red]([/color][/b]Me![audit_status] = "Pre-Closed" or me![audit_status] = "Closed"[b][COLOR=red])[/color][/b]


Randy
 
I get a '424' Object Required error

If Me![audit_posted_date] Is Not Null And (Me![audit_status] = "Pre-Posted") Then
MsgBox "Please make sure that the Audit Status is set to Posted", vbOKOnly, "Posted Date Verification"

End If


If I did not say it before, I really appreciate the time and expertise of the users on this forum.
 
In VBA you have to use the IsNull function:
If Not IsNull(Me![audit_posted_date])

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Bingo!!!!!!

Diod not know that .. many thanks PHV

If I did not say it before, I really appreciate the time and expertise of the users on this forum.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top