Weird 2448 run-time error. (1 Viewer)

Royce

Access Developer
Local time
Today, 07:15
Joined
Nov 8, 2012
Messages
99
I have a form that opens a report in a button click event.
DoCmd.OpenReport strReport, acViewPreview

The report has code in the Report_Open event to read a value on the form and change the RecordSource.

In the Report_Load event the following line Sometimes gives me a runtime error 2448. at the following line:
Me!Targetdate = Format(dtmStayDate, "Short Date")

Sometimes I get it when I use this instead:
Me.Targetdate.Value = Format(dtmStayDate, "Short Date")

When I get the error dtmStayDate is always 0. If I set a break in Report_Open, where dtmStayDate is set I almost never get the error. When I do, I never hit the break in Report_Open.

When I traced into Report_Open, one time I discovered the line:
DoCmd.Maximize was causing the code to skip the rest of Report_Open.

I haven't seen the problem since I commented out DoCmd.Maximize in the Report_Open event. (But then as it sometime worked, maybe I haven't tried enough?)

Has anybody seen this? What's going on?
 

JHB

Have been here a while
Local time
Today, 14:15
Joined
Jun 17, 2012
Messages
7,732
When it helps to put in a breakpoint then mostly a DoEvents also helps.
The DoEvents give the operating system time to finished processing.
So try to set in at DoEvents in your code:
Code:
DoEvents
Me!Targetdate = Format(dtmStayDate, "Short Date")
 

Users who are viewing this thread

Top Bottom