If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
How can i create a query thats lists options?
I have a database that I want to be able to query by having a drop down list
or a list where a user can select more than one value or posibly both. Can anyone help? |
#2
|
|||
|
|||
On Thu, 23 Jun 2005 05:23:04 -0700, "JP"
wrote: I have a database that I want to be able to query by having a drop down list or a list where a user can select more than one value or posibly both. Can anyone help? What do you want to do with these values once they're selected? You can't put multiple values into one field! It sounds like you need two Tables in a one-to-many relationship, and a Subform to edit them, rather than trying to get tricky with a combo box! John W. Vinson[MVP] |
#3
|
|||
|
|||
JP-
We've got something that kinda does that. With a form that pops up with three controls, a user is able to select from a list that populates based on a prior selection. Essentially, the values of the second combobox are populated based on the selection made in the first combo box: ProjectTypeComboBox (gets project types from an existing SQL query) ProjectNameComboBox (gets values based on what ProjectTypeComboBox is) CommandButton (for running it all in the end) ---------------------------------------------------------------------------------------------- for the ProjectNameComboBox, we put an [Event Procedure] in it's "After Update" Event. this, of course opens the VB scripting app. here is our code for that procedu Private Sub ProjectTypeCombo_AfterUpdate() Dim strSQL As String strSQL = ProjectTypeCombo.Value If strSQL = "Ship" Then ProjectCombo.RowSourceType = "Table/Query" ProjectCombo.RowSource = "Q-Ships" ProjectCombo.BoundColumn = 1 End If If strSQL = "Show" Then ProjectCombo.RowSourceType = "Table/Query" ProjectCombo.RowSource = "Q-Shows" ProjectCombo.BoundColumn = 1 End If If strSQL = "Project" Then ProjectCombo.RowSourceType = "Table/Query" ProjectCombo.RowSource = "Q-Projects" ProjectCombo.BoundColumn = 1 End If If strSQL = "Other" Then ProjectCombo.RowSourceType = "Table/Query" ProjectCombo.RowSource = "Q-Other" ProjectCombo.BoundColumn = 1 End If End Sub ------------------------------------------------------------------------------------------------ my CommandButton runs this procedure OnClick: Private Sub Go_SearchProjects_Click() '-- my commandButton Dim SQLString As String Dim TextObj As String TextObj = ProjectCombo.Value TextObj = Trim(TextObj) SQLString = "ProjectName =" & " '" & TextObj & "'" DoCmd.OpenForm "F-Projects", , , SQLString End Sub ------------------------------------------------------------------------------------------------ hope this gets you closer to your solution! /amelia |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
SQL query showing diff between actual and budget | Bon | Running & Setting Up Queries | 3 | August 25th, 2005 12:07 PM |
Too Few Parameters error Mail Merge Access Parameter Query | Tony_VBACoder | Mailmerge | 3 | September 14th, 2004 12:15 PM |
Taher | Setting Up & Running Reports | 1 | August 31st, 2004 09:07 PM | |
Query to join records form 2 databases | bdehning | General Discussion | 5 | August 9th, 2004 03:09 PM |
Hidden files in Ms-Query cause ODBC connect errors or Query is wac | needyourhelp | General Discussion | 4 | July 12th, 2004 09:38 PM |