OpenReport in a form's load event.

D

David Taylor

My Access app includes a form with the following bit of code in the load
event.

MsgBox "STUB 0", vbOKOnly
strWHERE = "[qryPreEval]!Evaluation_No = " &
Forms!frmcontractevaluation.Evaluation_No
DoCmd.OpenReport "rptEvaluations", acViewDesign, , , acHidden
MsgBox "STUB 1", vbOKOnly

This works fine in the mdb. But in the mde the second "MsgBox" never
executes. I would like to know what is causing this behaviour and how to
ensure that the mde executes the code that comes after the DoCmd.OpenReport
.... line.

Thanks in advance,

DT
 
S

Stefan Hoffmann

hi David,

David said:
MsgBox "STUB 0", vbOKOnly
strWHERE = "[qryPreEval]!Evaluation_No = " &
Forms!frmcontractevaluation.Evaluation_No
DoCmd.OpenReport "rptEvaluations", acViewDesign, , , acHidden
MsgBox "STUB 1", vbOKOnly

This works fine in the mdb. But in the mde the second "MsgBox" never
executes. I would like to know what is causing this behaviour and how to
ensure that the mde executes the code that comes after the DoCmd.OpenReport
... line.
This works for me. The only thing you have to consider is that opening
the report needs some time.

Test it with an unbound report.


mfG
--> stefan <--
 
D

David Taylor

The code that follows changes the report's recordsource.
AccessVandal via AccessMonster.com said:
Why is the report openning in Design View and hidden?

David said:
My Access app includes a form with the following bit of code in the load
event.

MsgBox "STUB 0", vbOKOnly
strWHERE = "[qryPreEval]!Evaluation_No = " &
Forms!frmcontractevaluation.Evaluation_No
DoCmd.OpenReport "rptEvaluations", acViewDesign, , , acHidden
MsgBox "STUB 1", vbOKOnly

This works fine in the mdb. But in the mde the second "MsgBox" never
executes. I would like to know what is causing this behaviour and how to
ensure that the mde executes the code that comes after the
DoCmd.OpenReport
... line.

Thanks in advance,

DT
 
S

Stefan Hoffmann

hi David,

David said:
The code that follows changes the report's recordsource.
In these cases I prefer binding the report to a report specific query
and changing the queries SQL statment:

Dim qd As DAO:QueryDef

Set qd = CurrentDb.QueryDefs.Item("reportSourceQuery")
qd.SQL = "new SQL statment"
Set qd = Nothing


mfG
--> stefan <--
 
D

Dirk Goldgar

My Access app includes a form with the following bit of code in the load
event.

MsgBox "STUB 0", vbOKOnly
strWHERE = "[qryPreEval]!Evaluation_No = " &
Forms!frmcontractevaluation.Evaluation_No
DoCmd.OpenReport "rptEvaluations", acViewDesign, , , acHidden
MsgBox "STUB 1", vbOKOnly

This works fine in the mdb. But in the mde the second "MsgBox" never
executes. I would like to know what is causing this behaviour and how to
ensure that the mde executes the code that comes after the
DoCmd.OpenReport ... line.


In an MDE, you can't open a report in design view, so the OpenReport call
will fail. You could use error-handling to trap and ignore that error, if
you want. But for an MDE, you'll need to find some other way to accomplish
your purposes than opening the report in design view.
 
K

Klatuu

I am suprised it works in mde at all. You can't make design changes in an
mde. Opening a report in design mode should not work in an mde.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top