Hello,
I want to create a button on a form that exports the current record on the form to a PDF of a report. I've taken the code i found here:
http://bytes.com/topic/access/answers/909411-can-i-use-docmd-outputto-export-current-record-only
and modified it to be this:
The form is based on the query "qry_Projec ts Credits". The primary key is "Project Number". The report i want to export to is called rpt_Projects Credits. When I try to run this i get the error:
Run-Time Error '3075': Syntax error (missing operator) in a query expression '[Project Number]='
When I click "Debug" it points to this line:
I have some experience with programming in C++ from a couple of courses i took a while ago (one first year university programming course and a robotics course later). I think i understand the logic that the code is trying to carry out but im still very new to VBA and am unfamiliar with the syntax.
Thanks,
Xenver
I want to create a button on a form that exports the current record on the form to a PDF of a report. I've taken the code i found here:
http://bytes.com/topic/access/answers/909411-can-i-use-docmd-outputto-export-current-record-only
and modified it to be this:
Code:
Private Sub Command481_Click() Dim strOriginalRecordSource As String Dim strNewRecordSource As String strOriginalRecordSource = Me.RecordSource strNewRecordSource = "SELECT * FROM [qry_Projects Credits] WHERE [Project Number] = " & Me![Project Number] Me.RecordSource = strNewRecordSource DoCmd.OutputTo acOutputReport, "rpt_Projects Credits", acFormatPDF, , True, "", 0 Me.RecordSource = strOriginalRecordSource End Sub
Run-Time Error '3075': Syntax error (missing operator) in a query expression '[Project Number]='
When I click "Debug" it points to this line:
Code:
Me.RecordSource = strNewRecordSource
Thanks,
Xenver
Comment