If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
VBA - Stuck with criteria for report
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 |
#2
|
|||
|
|||
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. -- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "Colin" wrote in message ... 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? |
#3
|
|||
|
|||
On Sun, 14 Aug 2005 13:03:42 +0100, Colin wrote:
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' -- Fred Please only reply to this newsgroup. I do not reply to personal email. |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
criteria, checkboxes, and/or | bicyclops | Running & Setting Up Queries | 4 | September 13th, 2005 10:47 PM |
Changing criteria in an access query based on a set of records in a table | New-user via AccessMonster.com | Running & Setting Up Queries | 3 | August 3rd, 2005 06:06 PM |
sorting more than 3 keys | Brooke | General Discussion | 3 | June 18th, 2005 04:52 AM |
dlookup documentation? | Fredrated | New Users | 1 | May 19th, 2005 11:10 PM |
Merging MS Word document with MS Access 2002 criteria query | Doug Robbins | Mailmerge | 2 | November 4th, 2004 05:57 PM |