I am trying to add a button to my form that opens a report for the current record being shown on the form but I am having no such luck. Any Ideas on how to do this easily?
I am trying to add a button to my form that opens a report for the current record being shown on the form but I am having no such luck. Any Ideas on how to do this easily?
What have you tried? Why doesn't it work - error message, wrong results, nothing happens?
Something like:
DoCmd.OpenReport "report name", , , "ID=" & Me.ID
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
This is currently what I have and it just returns the report unfiltered
OpenReport
Report Name:PurchaseOrder
View: Report
Filter Name:
Where Condition: "[TVCNo]=" & [Reports]![PurchaseOrder]![TVCNo]
Turn the wizard on, (on the toolbox , push the magic wand in)
grab a button, drag it to the form
it will ask you questions..select reports, the pick your report.
When its done you can look at the code behind the button.
Should reference the form, not report, as parameter: [Forms]!formname]!TVCNo
Is TVCNo a number or text type field? If text, need apostrophe delimiters:
Where Condition: "[TVCNo]='" & [Forms]!formname]!TVCNo & "'"
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
That did not work, it still only populates all of the records on the report, rather than the current record.
If you want to provide db for analysis, follow instructions at bottom of my post.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Private Sub cmdPrintPreview_Click()
Dim strReportName As String
Dim strCriteria As String
If NewRecord Then
MsgBox "aaaaaa." , vbInformation, "aaaaaa"
Exit Sub
Else
strReportName = "RptInvoice"
strCriteria = "[OrderDateID]= " & Me![OrderDateID]
'strCriteria = "[lngSalespersonID]='" & Me![lngSalespersonID] & "'"
DoCmd.OpenReport strReportName, acViewPreview, , strCriteria
End If
End Sub
VSC Master Database.beta - Copy.zip
I have attached the DB alot of information has been removed but i believe that form and report still work together, thanks for your help through this matter.
OK
Look at this