By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,671 Members | 1,315 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,671 IT Pros & Developers. It's quick & easy.

Using UniqueID numbers in a link criteria statement

P: 2
I am trying to resolve a problem where I need to create a report that is generated from the uniqueID number allocated in a table as an autonumber.
My code looks like this:

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "rpt Trial'"
stLinkCriteria = "[OpCommandID] = 1,3,4,7"
DoCmd.OpenReport stDocName, acPreview,,stLinkCriteria

It is the link criteria in line 4 that I cannot seem to get right. The intention is to put the details of unique ID 1, 3, 4 and 7 from a single table into the report. If I take out the '3,4,7' bit from the code, then the report generated reflects record 1 correctly. As soon as I add more numbers to the mix, I keep getting syntax errors.

Can anyone give me an idea of how I can do this? Thanks
Oct 15 '07 #1
Share this Question
Share on Google+
3 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
Hi Steve,

Try this ... (Not sure if it will work on the link criteria)

Expand|Select|Wrap|Line Numbers
  1.  Dim stDocName As String
  2.  Dim stLinkCriteria As String
  3.  stDocName = "rpt Trial'"
  4.  stLinkCriteria = "[OpCommandID] IN (1,3,4,7)"
  5.  DoCmd.OpenReport stDocName, acPreview,,stLinkCriteria
  6.  
Oct 15 '07 #2

P: 2
Hi Steve,

Try this ... (Not sure if it will work on the link criteria)

Expand|Select|Wrap|Line Numbers
  1.  Dim stDocName As String
  2.  Dim stLinkCriteria As String
  3.  stDocName = "rpt Trial'"
  4.  stLinkCriteria = "[OpCommandID] IN (1,3,4,7)"
  5.  DoCmd.OpenReport stDocName, acPreview,,stLinkCriteria
  6.  

Would never have thought that way but hey, it works perfectly. Thanks for your help.
Oct 15 '07 #3

MMcCarthy
Expert Mod 10K+
P: 14,534
Would never have thought that way but hey, it works perfectly. Thanks for your help.
You're welcome
Oct 15 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.