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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print Button on Popup Form

Status
Not open for further replies.

mikelev

Technical User
Mar 23, 2004
223
US
I have create a small popup form with the following fields:

Key (primary key, autonumbered)
Date
Amount
Strap Number

I have added a push button with the following code:

Private Sub Command15_Click()
DoCmd.OpenReport "rptStrapVariance", acNormal
DoCmd.OpenReport "rptStrapVariance", acNormal
End Sub


This report is based on a query that prompts the user to enter the KEY value from the form, and the report should print two times. Is there a way to limit this to a single prompt?

In addition even when I enter the KEY on screen into the prompt the report prints blank, it prints all prior KEY's numbers okay.

Thanks in advance





 
You can enter the criteria for the query as [form]![yourformname]![yourtexbox].value, and I believe there should be a way to have the report print two copies automatically via code, but I can't help you with that one. You can probably dop a search for it here. Hope this helps, Ken

- If you are flammable and have legs, you are never blocking a fire exit.
Mitch Hedburg
 
Changed the criteria on the query from [Enter Key#] to [form]![strapvar]![key].key.

The dialog bog info changed but same results?
 
I think [form]![strapvar]![key].key should be [form]![strapvar]![key].value
Ken

- If you are flammable and have legs, you are never blocking a fire exit.
Mitch Hedburg
 
Copy and pasted your text and same result.

I appreciate your help thus far
 
Closing the form, opening it, clicking the print button, and entering the previusly enetered KEY works? How can I keep from closing the form and reopening?
 
Hi, you might try just printing 2 copies with the printout command.

Something like:

DoCmd.OpenReport "rpt", acViewPreview
DoCmd.PrintOut acSelection, , , acMedium, 2

Hope that helps
 
Appreciate the shortcut to printing two reports, works great! But still am unable to print what I see on the form until i exit form and reopen?


 
Hi, I'm not entirely sure what you're asking there. One thing you can do is modify this slightly:

Private Sub Command15_Click()

docmd.minimize 'minimize the form
DoCmd.OpenReport "rpt", acViewPreview
DoCmd.PrintOut acSelection, , , acMedium, 2

End Sub

in the reports onClose event:

docmd.openform, "your form",acnormal 'restore the form

If you are printing what you see on the form, you might want to try using the form's filtered record source as the report
recordsource. That would eliminate a dialog box altogether.

Hope that helps.
 
Thanks to all that replied

This solved it!
Private Sub Command15_Click()

On Error GoTo Err_cmdPrintSelect_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Dim stDocName As String

stDocName = "rptStrapVariance"
DoCmd.OpenReport stDocName, acNormal
DoCmd.OpenReport stDocName, acNormal
DoCmd.Close acForm, "STRAPVAR", acSaveYes

Exit_cmdPrintSelect_Click:
Exit Sub

Err_cmdPrintSelect_Click:
MsgBox Err.Description
Resume Exit_cmdPrintSelect_Click

End Sub

Thanks to RoyVidars previous post


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top