Need help on report event (1 Viewer)

arage

Registered User.
Local time
Today, 07:03
Joined
Dec 30, 2000
Messages
537
Need help on report event
Hi,
My report has open event code that checks the month, and is supposed to print a particular budget amount in a certain report control (Text140). Problem is I get ‘expression has no value’ errors if my code looks like this:

If Month(Date) = 2 Then
DLookup("[febbudget]", "budgets", [RegionCode] = GlobalRegionCode) = Me.Text140
End If

And an ‘object required’ error if the above looks like this:

If Month(Date) = 2 Then
DLookup("[febbudget]", "budgets", GlobalRegionCode) = Me.Text140
End If

Since the regionCode value is blank in my 1st example, until the report is displayed, how can I assign it to GlobalRegionCode, which does have a value upon entry into the report? And if I delete regionCode completely as in the 2nd example, the Dlookup doesn’t know to use GlobalRegionCode against the regionCode field in “budgets” table when looking up the budget.

Please advise what event or programming procedure would be appropriate to fix my problem with my report.
 

Neal

Registered User.
Local time
Today, 07:03
Joined
Feb 17, 2000
Messages
116
Could you put your code behind the On Format or On Print event of the report header or details section? Those events occur after On Open and -- hopefully -- after your argument is available.
 

dlgates

Registered User.
Local time
Today, 07:03
Joined
Feb 21, 2001
Messages
12
First of all, your syntax may be causing various problems. Try something at least similar to ...

If Month(Date) = 2 Then
DLookup("[febbudget]", "budgets", "[RegionCode] = " & Me.Text140)
End If

I wasn't sure what you were trying to do since the criteria in DLOOKUP was not formatted as a string and it is also unclear if you are trying to test DLOOKUP's equality with a value but not inside an if clause, etc. A DLOOKUP function all by itself doesn't actually give you anything the way it was written.
 

dlgates

Registered User.
Local time
Today, 07:03
Joined
Feb 21, 2001
Messages
12
More... On second glance, maybe what you were trying to do was this:

me!Text140 = DLookup("[febbudget]", "budgets", "[RegionCode] = " & GlobalRegionCode)

I can begin to see some light in that...
 

arage

Registered User.
Local time
Today, 07:03
Joined
Dec 30, 2000
Messages
537
Actually dlGates, you're right w/your final advice, i have a working version of the report. But that has brought up other problems I'll take up in another thread.
 

Users who are viewing this thread

Top Bottom