Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I split a query between VB code and a Designed Query?

Status
Not open for further replies.

juschuma

Programmer
Oct 23, 2002
18
0
0
US
I have a rather complex SQL that is used to build/run a report. Part of the where clause I need to build in VB because it uses multiple rows from a multi-select listbox.

Can I only build that part of the where clause in VB and build the rest of the query in Design mode and somehow link the two together when I run the report?

Could I build the where clause from VB into a variable and have the Design part of the query reference that variable?

What about using the DoCmd.OpenReport and passing the Designed query as a filter query and the VB where clause as the Where clause of OpenReport?

Hope this all makes sense. Thanks.
 
Hi!

Design the query and base the report on it. Then build the where clause in your vba and pass it in the openreport:

DoCmd.OpenReport "Reportname", , , strWhereClause

In other words, use you second suggestion!

hth
Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top