AllExperts > Using MS Access 
Search      
Using MS Access
Volunteer
Answers to thousands of questions
 Home · More Using MS Access Questions · Answer Library  · Encyclopedia ·
More Using MS Access Answers
Question Library

Ask a question about Using MS Access
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Scottgem
Expertise
I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.

Experience
I've been designing databases for over 15 years working with dBase, FoxPro, Approach and Access.

Organizations
Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

 
   

You are here:  Experts > Computing/Technology > Business Software > Using MS Access > Same Query, Different Parameter

Using MS Access - Same Query, Different Parameter


Expert: Scottgem - 6/30/2009

Question
Hi Scott,

I'm sure this is a simple thing but I'm having trouble finding my way around it.

I have a stored query. I would like to run this query from two different command buttons which will prompt the user to input different parameters.

As an example:

SELECT M_TRequests.Trial_Request_ID, M_Product_Detail.MFG_Code, [Routingcommentsorig].[Pt Desc1] & " " & [Pt Desc2] AS Expr1
FROM M_TRequests, Routingcommentsorig INNER JOIN M_Product_Detail ON Routingcommentsorig.Part = M_Product_Detail.MFG_Code;

Pressing one command button would prompt the user to input a MFG Code and the other to input a Part.

At the moment I have two stored queries with the same fields just a different criteria. I would like to eliminate one of these and just use the one query and prompt the user to input a parameter depending on which command button is pressed.

Please help, thanks!


Answer
I would have the user input the criteria on the FORM. (I rarely use parameter prompt queries). Add a WHERE clause to your query:

WHERE MFG Like Forms!formname!cboMFGCode & "*" AND Part Like Forms!formanme!cboPart & "*"

On the form, add two comboboxes to select the MFGCode and Part. Then add a button to run the query.

Hope this helps,
Scott<>
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA  

Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.