View Full Version : Need help on report event


arage
02-22-2001, 06:37 AM
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
02-22-2001, 09:16 AM
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
02-22-2001, 09:22 AM
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
02-22-2001, 09:25 AM
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
02-22-2001, 09:48 AM
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.