Print current recrod information on letter in form?

G

Guest

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
 
G

Guest

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
 
G

Guest

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
 
Joined
Jul 10, 2007
Messages
1
Reaction score
0
moving active record to a report

This is exactly what I want to do. I want to push a button on my form and it will create a report of just the information in that record. I do not really sue code. can you give me an easy stepXstep to this?

Thanks.
=?Utf-8?B?Q2Fyb2wgU2h1?= said:
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


"Svetlana" wrote:

> 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
>
>
 

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