Forms, Subforms, and Print Preview

WillM

Registered User.
Local time
Yesterday, 20:04
Joined
Jan 1, 2014
Messages
83
Good afternoon!

I am attaching a picture of what I am talking about as this is going to get confusing...at least it is for me.

I have a Navigation Form that holds 7 tabs that pull reports or data entry forms.

I am trying to get the Preview Selected Record function to pull the UniqueID field from the Data Entry Form and generate a report for printing.

I can search by UniqueID in the data entry form with no problem, it is linked to two subforms with no problem.

Here is the code I have used most successfully:
Code:
[FONT=&quot]DoCmd.OpenReport "rpt1", acViewPreview,, "UniqueID =" & Forms!MainForm!NavigationSubform.Form.UniqueID [/FONT]
This actually works, but every time the print preview is closed, it crashes Access. I have researched this particular issue, and some of the solutions I have read and tried lead to "that method is not allowed or supported" errors or Run-Time 438 errors.

Any advice?

Thanks for your help!
 

Attachments

  • Capture.PNG
    Capture.PNG
    27.6 KB · Views: 218
Last edited:
1. If you open and close the report manually does it crash?
2. If you open the report without criteria and close it does it crash?
3. If you open any other report using the same method does it crash?
4. When you say "crash", what do you actually mean? Access actually closes completely or an error occurs?

When I say "you" I meant you two ;)
 
haha Thanks!

1. No, it opens and closes fine.
2. No
3. Appended - I got one other report to work without crashing using the above method.
4. The message " Microsoft Access has stopped working"..."will restart"...then prompts for backup.
 
Last edited:
I see. So Unique ID is a Number right?

Try this:
Code:
Dim lngUniqueID As Long

lngUniqueID = Forms!MainForm!NavigationSubform.Form.UniqueID

DoCmd.OpenReport "rpt1", acViewPreview,, "UniqueID = " & lngUniqueID
Do you have any code in the Close or Unload event of the report?
 
No code in close or unload of the subform in question, however in its parent form there is a macro(through macrobuilder) to open another form on close.

I tried the code you supplied and while it opened the form correctly, upon closing the form it crashed Access to the desktop and prompted a backup.
 
You say everything the print preview closes it crashes so I'm talking about the Close/Unload event of the report. Or does it force the form to close as well?

Can you upload a test db?
 
Sorry, I am not trying to be obtuse/cryptic. The report itself has no other code in it in either the unload or on exit, or anywhere else.

When I say it crashes, I literally mean it closes all of Access, the entire program. Also, I am able to get two other forms to work correctly with the print preview code, this particular form might just need to be redone. The same code works elsewhere, but this might just be a corrupt/bad form.

Unfortunately, I cannot upload a test db.
 
The same code works elsewhere, but this might just be a corrupt/bad form.
My thoughts precisely. It's not the first time navigation forms cause problems. In fact I was writing some code for a prototype once and I used a navigation form to test something out and after renaming the navigation form and deleting it, it caused my entire db to go haywire i.e. I couldn't run any code. There's something inherently wrong with navigation forms.

My advice to you is that you should only use it as a switchboard but if you're building a web database a navigation form is a must.

Unfortunately, I cannot upload a test db.
I'm not surprised ;) You guys never do.
 
Turned out to be a corruption. Had to end up rebuilding several forms and queries...not sure where it came from or how it happened, but we are making progress.

Thanks again for the help.
 

Users who are viewing this thread

Back
Top Bottom