Date defined report

K

K Crofts

Hi
I have a form with rows of information i.e. 1 row for each
customer. I have created a command button that will be
placed on the end of each row and when selected will print
only the information in that particular row, i have found
a problem however. My form is defined by a date field,
when i select the print option it prints the correct
fields on the report but prints them for every record, not
just the date selected. is there any way to amend the
below code so that the button will print the selcted date
only (which would also be the record in view)?
Private Sub Command84_Click()
On Error GoTo Err_Command84_Click

Dim stDocName As String

stDocName = "10aConf"
DoCmd.OpenReport stDocName, acNormal

Exit_Command84_Click:
Exit Sub

Err_Command84_Click:
MsgBox Err.Description
Resume Exit_Command84_Click

End Sub

Thanks in advance.
 
D

Duane Hookom

It would help if you provided the date control name on the form and also the
date field name in the report. It would be something like
Private Sub Command84_Click()
On Error GoTo Err_Command84_Click

Dim stDocName As String
Dim strWhere As String
strWhere = "[ReportDateField]=#" & _
Me.txtFormDateControl & "#"
stDocName = "10aConf"
DoCmd.OpenReport stDocName, acNormal, , strWhere

Exit_Command84_Click:
Exit Sub

Err_Command84_Click:
MsgBox Err.Description
Resume Exit_Command84_Click

End Sub

BTW: The command button wizard usually allows you to name controls. Consider
giving controls descriptive names in the future like:
cmdRun10aConfRpt
 

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

Similar Threads

Help!! 3
Specific report 2
Select printer 1
Printer selection 0
Sometime first record does not print 0
Check box dose not stop first report 0
Dynamic Naming of Form Button 3
Printing invoices 3

Top