Report for one record on a form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ac7rt
    New Member
    • Aug 2015
    • 1

    #1

    Report for one record on a form

    I'm making a database to show which types of devices are installed at intersections and I want the form to print out details for only one intersection and not our entire County.

    I'm getting an error message of "Syntax error (missing operator) in query expression."

    I have a report that has an underlying query field with the name of "Intersecti on Name". I also have a field on my form with the term "Intersecti on Name".

    Here is my VBA:

    DoCmd.OpenRepor t stDocName, acPreview, , "[Intersection Name]=" & [Intersection Name]

    If I understand correctly, "[Intersection Name]=" refers to my report field and the portion [Intersection Name] at the end refers to the field in my form and this VBA tries to match the form string for intersection name to the report string for intersection name.
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    Based on your field having the word "Name" at the end, I'm going to guess that that field's data type is Text. If that is the case, then you need quotes around the value that you are passing to it, like this:
    Code:
    DoCmd.OpenReport stDocName, acPreview, , "[Intersection Name]='" & [Intersection Name] & "'"
    However, that would cause a Data Type Mis-match Error, so we will need to see the SQL code for your query on which your report is based to be able to fix the error that you are getting.

    Comment

    Working...