Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide the Access Window 1

Status
Not open for further replies.

alananderson

Programmer
Jan 8, 2013
6
MW
thread702-1494964

Hi All,
I'm using Access 2003 and need to run my programme on 2003 and 2007 (at least)

I've used the code from FAQ705-2562 which is working really well for my forms but I'm getting error messages when I try to run reports. Error 2485: Microsoft Office Access can't find the macro 'DoCmd'

Any idea what I'm doing wrong.

Also, how have other people solved the issue of "hiding" a form once it has called another?

Regards,

Alan
 
One form "A" calls another "B" and first form "A" should be hidden. Various options:
(1) Form A calls form B as a dialog. In this case all processing of vba behind form A stops until B is finished. Form A can use the OpenArgs of form B to pass its own name, and form B, on opening, makes form A invisible. On return, form A can make itself visible, or B can do it if you prefer.
(2) Form A calls B but form A's code continues (normal, not dialog). In this case form A can make itself invisible, but form B will probably still need to be sent form A's name in its OpenArgs because on closing Form B, form B needs to make A visible.

Of course if A is the only form that ever calls B, you don't need to use OpenArgs because B can be hard-wired to do the necessary for A by name. I prefer OpenArgs because it means I can later decide to call B from some other form, and the whole system will still work.
 


If you just run the report and not preview, you will not get an error.

 
Hi,

jklo - I get the same error for preview and print. The code used for printing is :
DoCmd.OpenReport stDocName, acNormal - is this the problem?
Lionel hill - thanks for that but I really don't understand what you are saying.

My case involves a Main Menu (unbound form) which calls subsidiary menus (unbound forms) which call Forms and reports. I am currently writing "Forms!frmMenuMain.Visible = False" on each Command(Click) that calls up a form or report and then "Forms!frmMenuMain.Visible = True" on the exit command(Click) that returns to the previous menu. (I haven't got this far with reports yet)


Regards,

Alan
 
Hi All,

I found the problem with the print. JKLO is correct - printing without preview will work IF one does NOT put:

In the OnOpen: DoCmd.RunMacro "mcrRestore"
In the OnClose: DoCmd.RunMacro "mcrHide"

However, leaving that out means one can't preview reports.

Anyone have a solution please?

Regards,

Alan
 
From the example you are using:

5. Finally, to allow reports to be previewed...in every report you will need to put:

In the OnOpen: DoCmd.RunMacro "mcrRestore"
In the OnClose: DoCmd.RunMacro "mcrHide"

 
Hi,

I really do appreciate your help.

When I insert those lines in the on open and OnClose Events I get error message:

Error 2485: Microsoft Office Access can't find the macro 'DoCmd'

Any ideas?

Thanks,

Alan
 
Hi All,

Problem solved.

I had entered those lines on the corresponding lines of the report's property list. By changing those lines to event prcedure and placing these lines in code as in following example it now works :
Code:
Private Sub Report_Open(Cancel As Integer)
DoCmd.RunMacro "mcrRestore"
End Sub

Thanks for the help JK10
Regards

Alan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top