|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Queries - Use multiple queries
I have a search menu where the user can choose a search option:
1. Search by Date Filed 2. Search by Paid Date 3. Search by Invoice No. 4. Search by Client Name etc.... I have a query built for each of these options, 14 in all. Is there a way that I could have the user enter more than one option, and link those queries together? For example, they could enter 1 and 4 to search for Client Name on a particular filing date. I would rather not have to write a query for each and every option... Thanks. |
|
#2
|
||||
|
||||
|
Quote:
You would need to write VBA code to check every checkbox to see if it has been selected or not. Your code would then build the SQL syntax to do that. It's done all the time, but it can be quite a job to write it--and debug it, with that many options.
__________________
Experience is the thing you have left when everything else is gone. |
|
#3
|
|||
|
|||
|
Thank you...I'll see if I can figure out the code.
|
|
#4
|
|||
|
|||
|
If you're looking all this information up from one table you can do it with one query. Let's say you have 5 fields in your table and you want to be able to look up by any one of those 5 fields and you have a form that the user can put in their search criteria.
so Tbl_Test (void is a yes/no, purchdate is a date) Code:
Cust_ID PurchDate PurchAmt ItemID Void Now depending on the nature of your ID fields you could have one query that was (I'm assuming Cust_ID and Item_ID are numbers for the purposes of this example): now assuming your form that you set your criteria in is called Frm_Criteria and the fields are labeled Fld_001 through Fld_005 corresponding to the five fields: Code:
SELECT Tbl_Test.Cust_ID, Tbl_Test.PurchDate, Tbl_Test.PurchAmt, Tbl_Test.ItemID, Tbl_Test.Void FROM Tbl_Test WHERE (((Tbl_Test.Cust_ID) like "*" & [forms]![frm_criteria]![Fld_001] & "*") AND ((Tbl_Test.PurchDate) like "*" & [forms]![frm_criteria]![Fld_002] & "*") AND ((Tbl_Test.PurchAmt) like "*" & [forms]![frm_criteria]![Fld_003] & "*") AND ((Tbl_Test.ItemID) like "*" & [forms]![frm_criteria]![Fld_004] & "*") AND ((Tbl_Test.Void) like "*" & [forms]![frm_criteria]![Fld_005] & "*")); Something like this query will show pick up the value from your input form if it exists, if it doesn't it will pick everything. The only place you're run into trouble is if your ID is an autonumber then you would have to do something fancier to get that to come out right. If, however, you're using independently generated ID's (which I usually do) it should work fine.
__________________
---------------- If we've helped you and you have solved your problem please post that it's been resolved so we know! The suspense kills me! |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft Access Help > Queries - Use multiple queries |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
![]() |
|