I have a form "frmLocation" the form has a list box so the user can select
the location to run a query "qurEquipLocation" that is used to produce a
report "rptEquipLocation"
I have it set up so frmLocation opens you select the location and then click
OK when you click OK it opens frmEquipLocation in print preview...this all
works great.
Now what I would like to happen is once the report is open it closes the
frmLocation.
Here is the code I have and it does not do what I want.
I have tried this code on the OK button....
Private Sub cmdOK_Click()
DoCmd.OpenReport "rptEquipLocation", acViewPreview, "qurEquipLocation"
DoCmd.Close acFrom, "frmLocation"
End Sub
And I have have tried this code in the report in the On Open Event
Private Sub Report_Open(Cancel As Integer)
DoCmd.Close acFrom, "frmLocation", acSaveNo
End Sub
I am sure I am just missing one little thing...also if it makes any
difference frmLocation is a popup
Paolo - 18 Mar 2008 15:55 GMT
Hi Michelle,
If the code you posted is a verbatim copy of the code you tried to execute
you're missing nothing, 'cause is just a typo:
to identify a form in the close method it's not acFrom but acForm
HTH Paolo
> I have a form "frmLocation" the form has a list box so the user can select
> the location to run a query "qurEquipLocation" that is used to produce a
[quoted text clipped - 21 lines]
> I am sure I am just missing one little thing...also if it makes any
> difference frmLocation is a popup
Allen Browne - 18 Mar 2008 15:59 GMT
You have used acfROm instead of acfORm in both cases.
Presumably you are squashing errors, or Access would be reporting a problem
here.
It might be better to use the Close event of the report if the report's
query actually tries to do something with the form.

Signature
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
>I have a form "frmLocation" the form has a list box so the user can select
> the location to run a query "qurEquipLocation" that is used to produce a
[quoted text clipped - 22 lines]
> I am sure I am just missing one little thing...also if it makes any
> difference frmLocation is a popup