473,406 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How do you take the value of a dropdown list and put in into a query?

I have a database (access) of people and items associated with them. I am working on a form that has as listbox of all the names of the people, select the person you want and then click the button and it should run the query with the selected value from the listbox into the query? At the moment when i hit the button my query runs and returns all the people.... how do i get the selected value to be passed into the query?

Thanks

Ethan
Jul 3 '07 #1
1 931
devonknows
137 100+
I have a database (access) of people and items associated with them. I am working on a form that has as listbox of all the names of the people, select the person you want and then click the button and it should run the query with the selected value from the listbox into the query? At the moment when i hit the button my query runs and returns all the people.... how do i get the selected value to be passed into the query?

Thanks

Ethan
I believe you mean something along the lines of a drop down that has a list of options like Male/Female... i believe something like this.

Expand|Select|Wrap|Line Numbers
  1. Dim sqlStr as String
  2. If Not DropDown.Listindex = -1 Then
  3.     'ListIndex + 1 Because the Listindex Starts from 0 Where as the List Starts From 1
  4.     sqlStr = "SELECT * FROM MyDataBaseName WHERE Gender='" & DropDown.List(DropDown.ListIndex + 1) & _ 
  5.              "' ORDER BY Gender"
  6.  
  7.     'Execute your sqlString ... 
  8. End If
  9.  

Hope This Helps
Kind Regards
Devon
Jul 3 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Marc | last post by:
I've gotten everything up and running except for this -- I'd like to be able to have people have a dropdown list of cities in the US to use (or wherever) and not have to input them manually into a...
8
by: Lyn | last post by:
Hi, Can anyone tell me how the initial value displayed in Combo Box is determined when a form is opened? I am loading the dropdown from one field ("CategoryName") of a table, with "ORDER BY ". ...
15
by: sara | last post by:
Hi I'm pretty new to Access here (using Access 2000), and appreciate the help and instruction. I gave myself 2.5 hours to research online and help and try to get this one, and I am not getting...
2
by: Mad Scientist Jr | last post by:
I am populating a dropdownlist from SQL. The query returns the correct values (and no NULLs in any fields). The listitem.value is populated with an int ID field, and listitem.text with a varchar...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
1
by: Ben | last post by:
I have a formview with a few dropdownlists (software version, database version, etc). When a software version is selected, the database version dropdownlist updates itself accordingly. When in...
5
by: jung_h_park | last post by:
From: jung_h_park@yahoo.com Newsgroups: microsoft.public.dotnet.framework.aspnet Subject: Dropdown List not retaining its SelectedValue Date: Mon, 26 Jun 2006 21:02:57 -0700 Hello, My...
5
by: =?Utf-8?B?QnJlbmRlbiBCaXhsZXI=?= | last post by:
Hello. I am reading a value from a table and trying to determine if that value exists in a list of values associated with a dropdownlist. If so, I select the value, otherwise, I don't. I haven't...
1
by: waltnixon | last post by:
I've got an MS Access query which runs fine when double clicked and returns all of the rows in a test database I'm building. I've set up a multi group report based on the query. I immediately...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.