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

Need help with a print command button in a form

Status
Not open for further replies.
Nov 2, 2004
7
US
Was wondering if anyone can point me in the right direction. I know very basic C++ programming, not familiar with VBA at all.

I am trying to make a command button in a form. That will print that form’s current selected record information in the format of a report I have already created. I also need to tell it to print to a specific report based on a field value in that current record.

For example…

If I have a field named Company and the value is “A”, I want to print a report that I already have a specific layout for company “A”. I also need that report to only print that current record and not all the information based on the query it was created from.

If the value is Not “A”, I want it to print a different report that I have already laid out. But again I need it to print only that current record and not the query the report was originally created from or is currently tied to as the data source.


Any help would be appreciated

thanks
 
Hi

this is the code i used for a similar purpose

Private Sub apprnoprices_Click()
On Error GoTo Err_apprnoprices__Click

Dim stDocName As String
Dim stDocName1 As String
Dim stpsno As String
Dim stLinkCriteria As String
Dim strtitle As String
Dim strmsg As String
Dim intmsgdialogue As Integer
Dim intprintdocument As Integer

stLinkCriteria = "[LQ_PCSNo]=" & Me![LQ_PCSNo]

stDocName1 = "Doc1"
stpsno = [Forms]![Claims]![LQ_PCSNo]

strtitle = "Print Documents"
strmsg = "Do you wish to print?"
intmsgdialogue = vbYesNoCancel
intprintdocument = MsgBox(strmsg, intmsgdialogue, strtitle)

If intprintdocument = vbYes Then
MsgBox "You are now going to print the report for this record", vbInformation

DoCmd.OpenReport stDocName1, acNormal, "DM_Claim specific", "LQ_PCSNo =" & stpsno

ElseIf intprintdocument = vbNo Then
DoCmd.OpenReport stDocName1, acPreview, "DM_Claim specific", "LQ_PCSNo =" & stpsno

ElseIf intprintdocument = vbCancel Then
Me.Undo

End If




"DM_Claimspecific" replace with your query name.

"LQ_PCSNo = " replace with the Value field within the query (where value = "a")

stpsNo = replace with the field name of your form, where this will match the field of your report.

stdocname1 = replace with the report name



this actually prompts the user if they want to print the document, if they click on no, then it will just preview the report onto the screen.

this may help im not sure..

regards
Donna
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top