Running Report_Open Code

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

I am calling an Access Report from an Access VB Module. The Access Report has
Report_Open code that should execute when the report runs. When I call the
report from the VB code the report code does not execute. If I run the report
just by opening the report the code does execute. Calling the code from VB
had been working for years but now the Report_Open fails to even execute when
calling the report from VB code. Does anyone know why Access is doing this?
 
Dan,

1. What version of Access are you using?

2. What does the line of code look like that opens the report?

3. Is the report in the same mdb/accdb file as the code that opens it?

4. What does the code in the reports Open event look like? I assume you
have already tried putting a breakpoint in this code to see what is
happening. Have you opened the report in design mode and confirmed that the
Open event on the Events tab of the properties dialog says:
[Event Proceedure]? If not, check that.

HTH
Dale
 
Thanks for the reply.

the version is Access 2003

this is the code that opens the report from the VB module:
DoCmd.OpenReport "R_TicketSingle", acViewNormal

The report is in the same .mdb file

I have put a break point in the report code, when I open/run the report the
code does hit the break point. But when the report is called from the VB
module the code does not hit the break point.

The report does have the [Event Proceedure] on the "On Open". When I click
the "..." button it does take me to the code.


Dale Fye said:
Dan,

1. What version of Access are you using?

2. What does the line of code look like that opens the report?

3. Is the report in the same mdb/accdb file as the code that opens it?

4. What does the code in the reports Open event look like? I assume you
have already tried putting a breakpoint in this code to see what is
happening. Have you opened the report in design mode and confirmed that the
Open event on the Events tab of the properties dialog says:
[Event Proceedure]? If not, check that.

HTH
Dale

Dan said:
I am calling an Access Report from an Access VB Module. The Access Report
has
Report_Open code that should execute when the report runs. When I call the
report from the VB code the report code does not execute. If I run the
report
just by opening the report the code does execute. Calling the code from VB
had been working for years but now the Report_Open fails to even execute
when
calling the report from VB code. Does anyone know why Access is doing
this?


.
 
Sorry, Dan

Cannot say that I've ever run into that situation.

Have you tried putting the code in the Load event instead of the open event?
What does the code that is currently in the Open event do?

Dale

Dan said:
Thanks for the reply.

the version is Access 2003

this is the code that opens the report from the VB module:
DoCmd.OpenReport "R_TicketSingle", acViewNormal

The report is in the same .mdb file

I have put a break point in the report code, when I open/run the report
the
code does hit the break point. But when the report is called from the VB
module the code does not hit the break point.

The report does have the [Event Proceedure] on the "On Open". When I click
the "..." button it does take me to the code.


Dale Fye said:
Dan,

1. What version of Access are you using?

2. What does the line of code look like that opens the report?

3. Is the report in the same mdb/accdb file as the code that opens it?

4. What does the code in the reports Open event look like? I assume you
have already tried putting a breakpoint in this code to see what is
happening. Have you opened the report in design mode and confirmed that
the
Open event on the Events tab of the properties dialog says:
[Event Proceedure]? If not, check that.

HTH
Dale

Dan said:
I am calling an Access Report from an Access VB Module. The Access
Report
has
Report_Open code that should execute when the report runs. When I call
the
report from the VB code the report code does not execute. If I run the
report
just by opening the report the code does execute. Calling the code from
VB
had been working for years but now the Report_Open fails to even
execute
when
calling the report from VB code. Does anyone know why Access is doing
this?


.
 
Cannot say that I've ever run into that situation.

Have you tried putting the code in the Load event instead of the open event?
What does the code that is currently in the Open event do?

Whenever we see weird behavior like this, the compiled VBA code is
suspect.

I assume you have a good backup and you've already run Compact/Repair
on your database.

I suggest that you:

- use the under-documented /Decompile startup switch to make sure your
VBA isn't corrupted

If that doesn't work,

- make a brand new empty Access database, then copy all your objects
into it and try it from there.

Armen Stein
Microsoft Access MVP
www.JStreetTech.com
 
What is strange is the when I have the report in design mode and call the
report from the VB code it will execute the code every time. If I close the
report and run the VB code the report code does not execute.
 
What is strange is the when I have the report in design mode and call the
report from the VB code it will execute the code every time. If I close the
report and run the VB code the report code does not execute.

All the more reason to suspect the compiled VBA code. Did you try my
earlier suggestions?

Armen Stein
Microsoft Access MVP
www.JStreetTech.com
 
I needed to call the report from code to see why the report filtering was not
functioning. For some reason I needed to add Me.FilterOn = True to have the
report filter for just one item. For some reason the report stopped filtering
even though the Filter was filled in. My guess is the report was resaved with
FilterOn turned off. This cause the report to stop functioning.

As to the reason for my post. This is not a solved issue. When calling the
report from VB code DoCmd.OpenReport "R_TicketSingle", acViewNormal it will
skip showing the running of the Report Code. when it skipped this I was
unable to verify why my report filter was not working. It would just print
everything out.

If in the VB code I
DoCmd.OpenReport "R_TicketSingle", acDesign
DoCmd.OpenReport "R_TicketSingle", acViewNormal
DoCmd.Close acReport, "R_TicketSingle"

the code would now break inside the report where I had set the break point.
This is how I found out it was the Me.FilterOn was causing my problem.

I am not sure if this behavior is by design or not but I am glad I was able
to solve my issue. Thanks for the help.
 
Back
Top