Create a Query Form

D

Dwight

I have an application that is completely forms driven and I need to allow
users to create ad-hoc queries.

Does anyone have have suggestions or examples that I can reference?

Thanks in advance!

Dwight
 
O

Ofer Cohen

Not sure if that what you mean, but you can try something like:
Create a query, and use the code to change the sql within this query, and
then run it.
' To change the SQL in the Query
Application.CurrentDb.QueryDefs("Queryname").SQL = "Select * From TableName"
Docmd.OpenQuery "Queryname"
 
D

Dwight

I want to create a form which allows a user to create a query against the
tables in the database. The form needs to allow the user to select the
tables and fields, set criteria, sort, join, basically everything that can be
done within the MS Access query design window.

Thanks!
 
O

Ofer Cohen

In that case using the example I gave you you can do something like

Application.CurrentDb.QueryDefs("Queryname").SQL = "Select " & Me.FieldsName
& " From " & Me.TableName & " Order By " & Me.SortFieldName
Docmd.OpenQuery "Queryname"

I hope that this example gives you an idea
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top