VBA - Stuck with criteria for report

  • Thread starter Thread starter Colin
  • Start date Start date
C

Colin

Hi - I am trying to send some criteria to a report in Access using the code
below...

strCriteria = "[Person_Code]= " & Me!cboPerson & " AND [Form]= " &
Me![txtForm] & ""

The only problem is the AND part of the criteria complains that the syntax
is wrong - any suggestions?

Thanks,

Colin
 
Assuming that Form is a Text type field (not a Number type field), you need
extra quotes:

strCriteria = "([Person_Code] = " & Me!cboPerson & _
") AND ([Form] = """ & Me![txtForm] & "")"

The brackets are optional.
 
Hi - I am trying to send some criteria to a report in Access using the code
below...

strCriteria = "[Person_Code]= " & Me!cboPerson & " AND [Form]= " &
Me![txtForm] & ""

The only problem is the AND part of the criteria complains that the syntax
is wrong - any suggestions?

Thanks,

Colin

In addition to what Allen suggested, Form is a reserved Access/VBA/Jet
word and should not be used as a field name.
For additional reserved words, see the Microsoft KnowledgeBase article
for your version of Access:

109312 'Reserved Words in Microsoft Access' for Access 97
209187 'ACC2000: Reserved Words in Microsoft Access'
286335 'ACC2002: Reserved Words in Microsoft Access'
321266 'ACC2002: Microsoft Jet 4.0 Reserved Words'
 
Back
Top