Report Function

A

Anthony

I have a report and I have a table with Names, when I run the report I want
the user to select a name to print from on the report in a field that I set.
How would I go about setting this up. Thanks for your help.
 
S

StrayBullet via AccessMonster.com

Since Access reports are not interactive, you could use a form to allow the
user to choose the name, then a button to open the report.
 
A

Anthony

How could you go about doing this?

StrayBullet via AccessMonster.com said:
Since Access reports are not interactive, you could use a form to allow the
user to choose the name, then a button to open the report.
 
D

Duane Hookom

Start by creating a form with a combo box to select the primary key of the
record you want to report. Then, use the command button wizard to create a
button to open your report. Edit the code created by the wizard to apply a
where condition. Your code might end up something like this depending on your
controls and report names and data type of the field.

Private Sub cmdRptCustLabels_Click()
On Error GoTo Err_cmdRptCustLabels_Click

Dim stDocName As String
Dim strWhere As String 'added

stDocName = "Customer Labels"
If Not IsNull(Me.cboName) Then
strWhere = "[NameField]='" & Me.cboName & "'"
End If
DoCmd.OpenReport stDocName, acPreview, , strWhere

Exit_cmdRptCustLabels_Click:
Exit Sub

Err_cmdRptCustLabels_Click:
MsgBox Err.Number & vbCrLf & Err.Description
Resume Exit_cmdRptCustLabels_Click

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