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

Query from preselected items in form

Status
Not open for further replies.

cdl1701

Technical User
Dec 10, 2004
47
0
0
US
I had asked the question about creating a query and this was a good answer that I got.

==========================================================
***This was from a previous post in a differant thread***
How about a form with a combobox for the names and then have a query taking the choice from the form and use it as criteria? In your query, on the criteria line underneath the appropriate field, you'd type something like:
[Forms]![Timeline_Input_Form]![mmcid] or in general

[Forms]![FormName]![FormComboBoxName]
Note: The form must remain open. But you can hide it, or minimize it.

After they choose a name, you can have a command button to run the query which will pick up the needed info from the form.
==========================================================

Problem 1.
I got it to work okay but the query only runs right if only one item has the Criteria setup with this. If I place this in the other field criterias the query does not find anything. Once I edit the query and set it so that only one field has the criteria set up then it works again.. make sence?

Problem 2.
I also have some check boxes that I want the Query to use as well but I just cant seam to figure out the correct syntax to get it to work.

Please Help
Thanks
 
If you need criteria for different fields, are they "OR" or "AND"? This determines where on the grid you have to put the criteria. Some idea of the logic and requirements that you are trying to achieve might be of help.

Have fun! :eek:)

Alex Middleton
 
Let me tell you a little about what I am doing and maby that will help. I have a friend who has a NASCAR collection and he has so many that he has gotten to the point that he does not know what cars he has. He was bidding on a car on Ebay a while back on a car that he thought that he didn't have and won it... turns out he already had it. Enter the need for a searchable database. Since I had created databases in the past (years ago) I offered to create one for him. After I got started in this I quickly figured out that I had forgotten most of what I learned before. So here is where I am at.

The DB has 4 main searchable text fields that are list boxes.
Manufacturer
Scale
Year
Model

Then there are 10 or so Misc item check boxes
Autograph
Posters
Beanie Bears..
etc.

For my search I created an unbound form with combo boxes and check boxes that I could preselect the items that I want to search by. For example all cars made by Action (manufacturer) with a (scale) of 1/24 that are (autographed).
My search Query is set up like this

Manufacturer Scale Autograph
--------|-----------------------|---------------------|---------------
--------|-----------------------|---------------------|---------------
--------|-----------------------|---------------------|---------------
criteria|form!Search!manuf |form!search!scale | (not sure what to put here)

Your question above about the "AND" or "OR" rings a bell.
I hope this all makes sence
Thanks
Chris

Learning as I go...Again
 
Looks like you are on the right track. One thing you could do is view the query after making selections to figure out what is working and what isn't working. Trying removing and adding criteria to test. If the autograph field is yes/no, then you should be able to filter it directly to a check box. If the autograph is a string it gets a little tougher. You can use the form!search!chkBox as a field in the query to see what value is being picked up. Then use the field to generate the filter. Use may want to use
iif( form!search!chkBox, "Autograph", "") as filter to match. Your description calls for AND, if a and b. OR would be criteria on different lines for A or B.
 
Where would I need to put the AND at? I thik this is what I am missing.

Manufacturer Scale Autograph
--------|-----------------------|---------------------|---------------
--------|-----------------------|---------------------|---------------
--------|-----------------------|---------------------|---------------
criteria|ANDform!Search!manuf|ANDform!search!scale|

Something like this?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top