printing a report from a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to preview a quote proposal from a quote form. I put the button
on the form using the wizard. It prompted what report to preview but I would
like it to preview only the page where the quote id= the quote id of the form
I am currently on. Would prefer not to be prompted to put in the quote id -
like a parameter query. I know for the forms operations it prompts would you
like to go to a certain record on the form. did I miss it. I'm sure I
probably can add some VB code to the on click event of the button - the field
is quoteid- on the form and on the report. Please help with the exact code
and am I on the right track??

Thanks,
Barb
 
Button to print specific record
Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.

Me.Dirty = False

End If

If Me.NewRecord Then 'Check there is a record to print

MsgBox "Select a record to print"

Else

strWhere = "[ID] = " & Me.[ID]

DoCmd.OpenReport "MyReport", acViewPreview, , strWhere

End If

End Sub



Notes: If your primary key is a Text type field (not a Number type field),
you need extra quotes: strWhere = "[ID] = """ & Me.[ID] & """"

If you want the report to print without preview, replace acViewPreview with
acViewNormal.



See also: http://allenbrowne.com/casu-15.html
 
Back
Top