use a drop-down list for a parameter query

mgonzales

Registered User.
Local time
Today, 08:11
Joined
Sep 16, 2009
Messages
44
One of my fields is a dropdown list. I'd like to query by that field and I want the user to chose from one of the pre-populated options. Is there a way to create a parameter in queries that will allow this?
 
1. Your fields should not be using lookups at table level.

2. You do this on a FORM.
 
I agree with Bob abouth the lookup at table level issue,

In your query criteria you can put something like: [Choose one S,B,F] (Where S,B,F are the options in your combo box) If there are a ton of them you don't have to put, the SBF part, especially if it is some data that people are used to.

Another and probably better way to do it is to have a form that has the combo box and either a subform or list box that will filter by the selection in the combo box. The subform or list box would have it's record source as the query. In the query the combo box field would lookup up from the combo box (You can use the build function in the criteria for that field). If you just want the query to pop up you can make a button do the same thing.
 
Sorry I should clarify....
I have the drop-down in my form. I need to report on certain information in that form. So I am creating a query and basing the report off that query. Queries allows you to create parameters so you can pull certain information. When a user opens my report I want them to have an option of what data they'd like to report out. I was hoping that there is a parameter that I can place in the criteria field for that particular item in my query, that will allow users to chose from a list of items, instead of typing their item in the pop-up parameter window when they open the report.
 
Sorry I should clarify....
I have the drop-down in my form. I need to report on certain information in that form. So I am creating a query and basing the report off that query. Queries allows you to create parameters so you can pull certain information. When a user opens my report I want them to have an option of what data they'd like to report out. I was hoping that there is a parameter that I can place in the criteria field for that particular item in my query, that will allow users to chose from a list of items, instead of typing their item in the pop-up parameter window when they open the report.
You do that with a form reference to a control. See this sample for an example.
 
Sorry I should clarify....
I have the drop-down in my form. I need to report on certain information in that form. So I am creating a query and basing the report off that query. Queries allows you to create parameters so you can pull certain information. When a user opens my report I want them to have an option of what data they'd like to report out. I was hoping that there is a parameter that I can place in the criteria field for that particular item in my query, that will allow users to chose from a list of items, instead of typing their item in the pop-up parameter window when they open the report.

Create a form that has all of the options on it, and make your report query read the values from the form. You would select the values, click a button and the report would open.
 
boblarson and Kryst51 you two are genius! This is exactly what I was looking for! Thanks!!!!:D
 
I have tried to replicate the form that boblarson had a sample of but I cannot get mine to work. I am using the Select by CompanyName example. I entered in all my information into the code, but when I click the Open button it gives me a popup window stating "Enter Parameter Value". This command button is just suppose to pull up the report based off the dropdown menu selection and it does not do that. What am I doing wrong?
 
I have tried to replicate the form that boblarson had a sample of but I cannot get mine to work. I am using the Select by CompanyName example. I entered in all my information into the code, but when I click the Open button it gives me a popup window stating "Enter Parameter Value". This command button is just suppose to pull up the report based off the dropdown menu selection and it does not do that. What am I doing wrong?

Can you post what you currently have?
 
This is the code that I have.
Private Sub cmdOpReportingPeriod_Click()
' this opens the report in preview mode and you select the customer using the single quotes because Me.cboCompanyName
' returns text and text needs to be surrounded by quotes.
DoCmd.OpenReport "rptReporting", acViewPreview, , "[ReportPeriod]='" & Me.cboReportingPeriod & "'"
End Sub

Should I also post the DB?
 
This is the code that I have.
Private Sub cmdOpReportingPeriod_Click()
' this opens the report in preview mode and you select the customer using the single quotes because Me.cboCompanyName
' returns text and text needs to be surrounded by quotes.
DoCmd.OpenReport "rptReporting", acViewPreview, , "[ReportPeriod]='" & Me.cboReportingPeriod & "'"
End Sub

Should I also post the DB?

Yes, I meant post the database. But in the meantime, is ReportPeriod actually text in the table or number? If number it would be:

DoCmd.OpenReport "rptReporting", acViewPreview, , "[ReportPeriod]=" & Me.cboReportingPeriod

Also, make sure that the combo box is returning the value you think it is. Put a message box before the code like

MsgBox Me.cboReportingPeriod

to see if you are getting what you think it should be returning.
 
The ReportPeriod is a text field.
I tried to attach my DB but it is too large. How do I compress it to send?
 
The ReportPeriod is a text field.
I tried to attach my DB but it is too large. How do I compress it to send?

First go do a COMPACT AND REPAIR and then right-click on the file and select SEND TO > COMPRESSED FOLDER
 
Thanks that helps. This is going to take me a bit as you are trying to use Reporting period but the data is not saved by reporting period. You need something to convert this to work. I may have to work on this at home tonight.
 
Oh my, is there anything that I can start to make this DB feature work? I really do appreciate all your help with this! Thanks a ton!
 
Thanks that helps. This is going to take me a bit as you are trying to use Reporting period but the data is not saved by reporting period. You need something to convert this to work. I may have to work on this at home tonight.
Hi Boblarson...did you have any luck with this DB?
 
Sorry, totally slipped my mind. So, what is the report based on? The tblActivity start date and end date (anything fitting between those which fit into the reporting period of tblLeadership reporting)?
 

Users who are viewing this thread

Back
Top Bottom