help with syntax code behind from

freightguy

Registered User.
Local time
Today, 02:32
Joined
Mar 1, 2016
Messages
36
Hi All - I'm using code from http://www.baldyweb.com/multiselect.htm and hit a snag.

Code:
DoCmd.OpenReport "rptTSCA", acPreview, , " dbo_tblARInvoice![strOrderNumber] IN(" & strWhere & ")"

I'm not sure what the proper VBA syntax is when referring to a specific field in my query.

Table: dbo_tblARInvoice
Field: strOrderNumber
query name: qryToxic

Can anyone suggest the right syntax?

thank you
 
Try

DoCmd.OpenReport "rptTSCA", acPreview, , "strOrderNumber IN(" & strWhere & ")"
 
thanks Paul - that was my first try and it caused a message to pop up asking me to enter a parameter value and if I enter a value, the report does run however it returns all records and does not filter any of it.
 
The prompt is Access telling you it can't find something. Is that the correct spelling of the field name? Can you attach the db here?
 
yep, working on it! It's part of a much larger db. Will upload it soon as I can.
Cheers!
 
Hi Paul - db had over 155 Mb and needed to delete and scrub so now you only one option to select from list box. The result however should return 7 lines of data on the report (see attached report for result). It works if I enter the proper data in my query but when I try to run it through the form code it bombs every which way I try.

See attached zip file of db as well as print out of what result should look like.

thanks for helping me out.
 

Attachments

Two problems. First, the field is spelled correctly but is not in the record source of the report. Second, the field is text, so needs the delimiters around it as noted in the link where is says "Use this line if your value is text". If I make those changes, it returns the desired result.
 

Users who are viewing this thread

Back
Top Bottom