Display the results of a select query. (VB)

Rashers

New Member
Joined
Jul 24, 2003
Messages
31
Hi all,
I'm sure there is a simple solution to this, I just can't find it.

What I want to do is to build an SQL Select query based on a number of inputs gotten from a user. In other words, build a string, execute it as an SQL statment and display the result to the user.

The closest I've come to this is DoCmd.runSQL(), but that doesn't seem to allow Select statements.

Any ideas or comments would be much appreciated.

Regards,
Andrew
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
I suppose it could be simple or very complex depending on what level of flexibility you're wanting to allow for the construction of your SQL. I actually just built a Pass-Through query builder which allows users to access an external data source without having to actually know SQL. It's very complex as I had to allow for any number of field headings, Criteria, etc. and I had to build a Results subform on the fly as there is no way to tell ahead of time how many fields will be in the result set. Like I said, it's really complex and may just confuse you, but if you think it'll help, I can send you a scaled-down version (i.e. it won't actually access the server, but it will show you how to build dynamic SQL).
 
Upvote 0
Actually, I've discovered a workaround. It's kinda complex but it involves setting up a number of reports and then opening them in print preview view. Seems to be working, though I still have to iron out a few issues. Thanks for your help.
 
Upvote 0

Forum statistics

Threads
1,221,618
Messages
6,160,872
Members
451,674
Latest member
TJPsmt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top