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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question about queries using forms

Status
Not open for further replies.

kjspear

Programmer
Feb 13, 2002
173
US
Hello everyone,

I have a question about queries by forms. I developed a query and a form so that a user can enter a query in the field of the form. I result from the query is then displayed in the query table.

The problem I'm having after checking several tutorials for answers, is how can I get the form to look up queries from whatever the user Checks off on the form? I see how it can be done if the user enters a value in the field but what about the check boxes?

What I'm trying to do is simply have a query executed based on whatever is checked off by the user.

For example, User wants to see a listing of all members who reside in NJ, he/she checks off the box. The user also wants to see how many are Gold Members in from the NJ results.

Any suggestions on how this can be done? I'm using Access 2002. I'm trying to avoid creating a query for every field.

I hope my question was clear.

Thanks
KJ
 
I assume you have three checkbox related to 3 fieldnames. You can create query based on the checkboxs like this

Dim mSqlText As String
mSqlText = "SELECT FieldA, FieldB, FieldC, FieldD FROM TableA WHERE "
IF Me.CheckBoxA = False Then mSqlText = mSqlText & "FieldA = "NY"
and so on
Then Youcan Use the query, like
DoCmd.RunSQL mSqlText

I hope that's what you mean. May be it's not clear enough so the other didn't anser your question
C U
 
Yes. That's what I mean. If the checkbox is checked, then the value associated will be queried.

So basically, since the user may want various queries, rather than racking my brains on figuring out what reports they need,I came to the conclusion to let them select whatever they feel necessary.

Also, do you know of a good book or tutorial that involves mainly queries?


Thanks
Kyle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top