Print current recrod information on letter in form?

S

steph44haf

Here is the code for my command button - how can I change it to only print
the data on the current record of the form I am in. (instead of all the
records)

Private Sub Print_Report_Click()
On Error GoTo Err_Print_Report_Click

Dim stDocName As String

stDocName = "Investments"
DoCmd.OpenReport stDocName, acNormal

Exit_Print_Report_Click:
Exit Sub

Err_Print_Report_Click:
MsgBox Err.Description
Resume Exit_Print_Report_Click

End Sub
 
S

steph44haf

Thanks, but that didn't work - it printed the form - not the report. I was
hoping to print the report (letter) I created with the data from the current
record out.

???
 
S

Svetlana

Then you need just to specify where criteria

Dim strDocName As String
Dim strLinkCriteria As String

strDocName = "Investments"
strLinkCriteria = "[Report'sFieldName]=" & Me![Form'sFieldName]


DoCmd.OpenReport strDocName, , , strLinkCriteria
 
C

Carol Shu

Hi, i was trying to do the same thing, the problem is the preview shows all
the fields but was no information, like the name, address..could you help me?
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 point
MsgBox "select a record to print"
Else
strwhere = [Mailing ListID] = "&me.[Mailing ListID]"
DoCmd.OpenReport "Mailing List", acViewPreview, , strwhere
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top