By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,327 Members | 1,791 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,327 IT Pros & Developers. It's quick & easy.

Creating an IF/AND statement

P: n/a
This is probably very easy but I'm not experienced with writing code.
Here's what I'm trying to do:

I want to print a report that has text "Unapproved Document" at the top
if two conditions are met:
1. PriceIncrease field is checked (true)
2. Approval field is Null

If the conditions are not met, then the words "Unapproved Document"
will not appear in the report.

The report pulls these fields from a query called OAQuery. I created
an unbound text field in the report named "ApproveWarning" that will
act as a container to put the words "Unapproved Document".

Here's my code, which is getting a runtime error:

Private Sub Report_Open(Cancel As Integer)

If OAQuery.PriceIncrease = True Then
If OAQuery.Approvel = Null Then
Me!ApproveWarning = "UNAPPROVED DOCUMENT"
Else
Me!ApproveWarning = Null
End If
End If
End Sub

What am I doing wrong??

Nov 30 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
try
If OAQuery.Approvel = Null Then
If IsNull(OAQuery.Approvel) Then
"Swinky" <sw********@lunt.comwrote in message
news:11**********************@l12g2000cwl.googlegr oups.com...
This is probably very easy but I'm not experienced with writing code.
Here's what I'm trying to do:

I want to print a report that has text "Unapproved Document" at the top
if two conditions are met:
1. PriceIncrease field is checked (true)
2. Approval field is Null

If the conditions are not met, then the words "Unapproved Document"
will not appear in the report.

The report pulls these fields from a query called OAQuery. I created
an unbound text field in the report named "ApproveWarning" that will
act as a container to put the words "Unapproved Document".

Here's my code, which is getting a runtime error:

Private Sub Report_Open(Cancel As Integer)

If OAQuery.PriceIncrease = True Then
If OAQuery.Approvel = Null Then
Me!ApproveWarning = "UNAPPROVED DOCUMENT"
Else
Me!ApproveWarning = Null
End If
End If
End Sub

What am I doing wrong??


Nov 30 '06 #2

P: n/a
Just a guess: Are the Fields "Approve1" and "ApproveWarning" in the Record
Source for the Report, but not displayed directly in Controls on the Report?
Access' Reporting "helps us out" by not having available those fields in the
Record Source that aren't displayed in Controls on the Report -- to make our
processing more efficient. If you don't have those on the Report, create
Text Boxes for them, but set their Visible property to No, and then try
again.

Larry Linson
Microsoft Access MVP
"Swinky" <sw********@lunt.comwrote in message
news:11**********************@l12g2000cwl.googlegr oups.com...
This is probably very easy but I'm not experienced with writing code.
Here's what I'm trying to do:

I want to print a report that has text "Unapproved Document" at the top
if two conditions are met:
1. PriceIncrease field is checked (true)
2. Approval field is Null

If the conditions are not met, then the words "Unapproved Document"
will not appear in the report.

The report pulls these fields from a query called OAQuery. I created
an unbound text field in the report named "ApproveWarning" that will
act as a container to put the words "Unapproved Document".

Here's my code, which is getting a runtime error:

Private Sub Report_Open(Cancel As Integer)

If OAQuery.PriceIncrease = True Then
If OAQuery.Approvel = Null Then
Me!ApproveWarning = "UNAPPROVED DOCUMENT"
Else
Me!ApproveWarning = Null
End If
End If
End Sub

What am I doing wrong??

Dec 1 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.