OnOpen event property error

betsyr

Registered User.
Local time
Today, 16:46
Joined
Nov 1, 2001
Messages
17
In trying to open a report, double clicking on it from the database window, the following error message shows up. I cannot figure out why it is being generated.

Error message:
The expression on open you entered as the event property setting produced the follow error:.
*The expression may not result in the name of a macro, the name of a user defined function or [Event Procedure].
*There may have been an error evaluating the function event or macro.

Here is the code behind the report:

Option Compare Database
Option Explicit

'I have commented out all other code in the module including the on no data event.

Private Sub Report_Open(Cancel As Integer)
Dim recSrc As String

recSrc = "SELECT * FROM [YearEndAcctRecQuery] WHERE ([YearEndAcctRecQuery].[DateSold] >= #1/1/2001# AND [YearEndAcctRecQuery].[DateSold] <= #1/1/2002#) AND [Recieved] = False;"
Me.RecordSource = recSrc
End Sub


When I paste the sql into a new query and run it, it works just fine and returns records. I also re-did the whole event procedure, (deleted [Event Procedure] from the onOpen event and started over) and that did not help either.

Any help would be greatly appreciated, I am tearing my hair out!!

betsyr
 
Well, what I am really doing is grabbing those dates from a form that is used to open the report. The user can fill in whatever date range they want to see, so the SQL will change every time the report is opened. The reason I have dates filled in is that I wanted to make sure that my problem was not a problem with the SQL statement itself. I took out the reference to the form fields and put in actual dates because I can make sure that the SQL will bring back results when I paste it into a query.

Is that what you meant?

If you think there is a better way or that this may be the source of my problem, I am open to other suggestions! I am using this same scenario for many other reports and have not run into this problem before!

Thanks for the response.
 
Wait...I am so sorry, suddenly it is working, I have no idea why...Access can be so weird sometimes. Thanks for your time, and I guess the lesson to be learned is, when in doubt, reboot.
 

Users who are viewing this thread

Back
Top Bottom