A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

VBA - Stuck with criteria for report



 
 
Thread Tools Display Modes
  #1  
Old August 14th, 2005, 01:03 PM
Colin
external usenet poster
 
Posts: n/a
Default 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  
Old August 14th, 2005, 01:30 PM
Allen Browne
external usenet poster
 
Posts: n/a
Default

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  
Old August 14th, 2005, 05:26 PM
fredg
external usenet poster
 
Posts: n/a
Default

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 04:04 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.