Form Filtering in a Report

rachel_harder

Registered User.
Local time
Today, 16:13
Joined
Feb 4, 2015
Messages
13
Hello all,
I know that this has been discussed before but I can't seem to make it work for me. I am using Access 2010 and am trying to get a form emailed with outlook. I have set up a Macro that will open a report from my form and then attach the report to an email as a PDF. But what I can't seem to figure out is how to make the report only open the current form record I am looking at. I have done some research and found a VBA code that reads

Private Sub Report_Open(Cancel As Integer)
Me.Filter = "PI_SheetID='" & Forms![Frm_CompletedPartSearch]![PI_SheetID]
Me.FilterOn = True
End Sub

and I have put that on my open event for the report. But every time the report opens I get an error that says

Syntax error in string in query expression '(PI_SheetID='175)

That ID number is the record number for the first report that I am trying to email. Also it doesn't matter what record I am looking at when I try to open the report I get the same error message. If any one could help me I would appreciate it. Thank.
 
Syntax error in string in query expression '(PI_SheetID='175)

numbers do not use quotation marks, try

Me.Filter = "PI_SheetID=" & Forms![Frm_CompletedPartSearch]![PI_SheetID]
 
Thank you so much. That fixed my issues.
 

Users who are viewing this thread

Back
Top Bottom