Strange print problem!!! (1 Viewer)

rede96

Registered User.
Local time
Today, 16:21
Joined
Apr 2, 2004
Messages
134
Ok, I am quite experienced with database, forms, vba etc. but have never come across this issue before.

I have a form a user opens and enters data. When the user has finished entering data the user will press a command button the will print a report. This is hard coded using VBA, so I know the report name is correct and the report opens in print preview mode no issues.

The user then presses 'Print' in the top right of the screen to print the report that has just opened.

However! Instead of the report being printed the underlying form is printed.:confused::confused::confused:

This only happens on the first one or two tries. Then for no understandable reason the report will print as intended following the exact same procedure that caused the problem in the first place.

Has anyone ever come across this problem before?
 

Minty

AWF VIP
Local time
Today, 16:21
Joined
Jul 26, 2013
Messages
10,371
Can you show us the code behind the print preview button please.
It sounds as if focus is being moved off the print preview.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:21
Joined
May 7, 2009
Messages
19,245
Are you using PrintOut command. you shoul use DoCmd.Open acReport with your report name.
 

rede96

Registered User.
Local time
Today, 16:21
Joined
Apr 2, 2004
Messages
134
Can you show us the code behind the print preview button please.
It sounds as if focus is being moved off the print preview.

Are you using PrintOut command. you shoul use DoCmd.Open acReport with your report name.

Yes I use the docmd.openreport

Code:
DoCmd.RunCommand acCmdSaveRecord 
DoCmd.OpenReport "On Receipt Worksheet Rpt", acViewPreview, , "[ReturnID] =" & Me.ReturnID

I am going to change it so it prints normal without opening the report first, see if that resolves it. But I just can't understand why it is only an intermediate problem.

I have followed the print procedure in the form myself. Done it twice in exactly the same way but go two different print outs!
 

isladogs

MVP / VIP
Local time
Today, 16:21
Joined
Jan 14, 2017
Messages
18,227
Perhaps your form or report are corrupted.
Save your report temporarily with a different name
Then create a new report with the original name & see if that opens correctly in print preview
If it does, then there is an issue with your original report

Return to the original report & try saving the Me.ReturnID as a variable e.g lngID
Then use the variable in the print preview code
Does that now work correctly first time?
If not, there is an issue with your form

At this point, try DECOMPILING to remove any compile code
Try to preview the report again

As a final resort, try recreating your report and/or form from scratch depending on the earlier results
 

rede96

Registered User.
Local time
Today, 16:21
Joined
Apr 2, 2004
Messages
134
Perhaps your form or report are corrupted.
Save your report temporarily with a different name
Then create a new report with the original name & see if that opens correctly in print preview
If it does, then there is an issue with your original report

Return to the original report & try saving the Me.ReturnID as a variable e.g lngID
Then use the variable in the print preview code
Does that now work correctly first time?
If not, there is an issue with your form

At this point, try DECOMPILING to remove any compile code
Try to preview the report again

As a final resort, try recreating your report and/or form from scratch depending on the earlier results

Hi Colin,

Thanks for the tips. I'll try them out this week and feedback. Cheers.
 

JHB

Have been here a while
Local time
Today, 17:21
Joined
Jun 17, 2012
Messages
7,732
What happen if you click on the report, before you presses 'Print' in the top right of the screen?
Do you've more code behind the command button?
 

Users who are viewing this thread

Top Bottom