A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

How can i create a query thats lists options?



 
 
Thread Tools Display Modes
  #1  
Old June 23rd, 2005, 01:23 PM
JP
external usenet poster
 
Posts: n/a
Default 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  
Old June 23rd, 2005, 07:17 PM
John Vinson
external usenet poster
 
Posts: n/a
Default

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  
Old June 24th, 2005, 07:23 PM
aaearhart
external usenet poster
 
Posts: n/a
Default

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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
Print 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


All times are GMT +1. The time now is 08:05 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.