Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / November 2004

Tip: Looking for answers? Try searching our database.

How do I pass the value from a list box into a query?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andrew - 02 Nov 2004 18:21 GMT
I've got two tables in my DB, a Client table and an Event table.
There are many events for each client.  The form I designed is based
off of the Client table and the subform within it is sourced from the
Event table.

The way things are currently designed places a list of clients on the
left side of the form (with a list box), and then there's a subform on
the right side of the main form with fields to enter event
information.

What I'd like to have happen is to simply select a client name from
the left side, enter the event information on the right and click
submit, and then move on selecting other clients, etc.  Right now I
have a list box
providing the client list.  Is this right?  I know there's an option
when using the listbox wizard that involves using a record selected in
the list box for other functions, but I can't figure out how that
works exactly.

Thanks,
Andrew
Mal  Reeve - 02 Nov 2004 23:36 GMT
Andrew,
Rather than the Left side of the form, go to Design View and view the Form
Header/Footer.
If you create a combobox that gets its data from the same source as the
listbox (and use the wizard to create it)  The option of  "Find a record on
my form..." will be available.
While you don't need to stick with the Combobox, it will show you the
appropriate code to use.
Personally though I would use a combobox for this type of
application....especially if the client list grows to a long long list...a
lot less scrolling with the combobox.

HTH
Mal.

> I've got two tables in my DB, a Client table and an Event table.
> There are many events for each client.  The form I designed is based
[quoted text clipped - 17 lines]
> Thanks,
> Andrew
Andrew - 03 Nov 2004 15:49 GMT
Thanks for the help Mal.  I'd rather use a list box if possible since
1) the client list will rarely get longer than 25 and 2) the people
using the system will have a much easier time with a list box than a
combo box (not the most computer savvy folks).  If I just change the
type from a combo to a list is there anything else I'd have to take
into consideration?

Thanks,
Andrew

> Andrew,
> Rather than the Left side of the form, go to Design View and view the Form
[quoted text clipped - 10 lines]
> HTH
> Mal.
Mal  Reeve - 04 Nov 2004 02:46 GMT
I don't think anything else would need changed...

look in help for the .selected
which is what you want....
If its a simple list box (only one selection allowed)
then I think that using the value will work the same way as the code
produced by the wizard.

Mal.

> Thanks for the help Mal.  I'd rather use a list box if possible since
> 1) the client list will rarely get longer than 25 and 2) the people
[quoted text clipped - 23 lines]
>> HTH
>> Mal.
Mal  Reeve - 04 Nov 2004 02:48 GMT
Another thought...

Use a combo-box, and the code auto generated....
And use the On Open event of the form to set the combobox as dropped.

txtComboBoxClientList.Dropdown

Making it look an awful lot like a listbox...

Mal.

> Thanks for the help Mal.  I'd rather use a list box if possible since
> 1) the client list will rarely get longer than 25 and 2) the people
[quoted text clipped - 23 lines]
>> HTH
>> Mal.
Pieter Linden - 04 Nov 2004 15:41 GMT
> I've got two tables in my DB, a Client table and an Event table.
> There are many events for each client.  The form I designed is based
[quoted text clipped - 17 lines]
> Thanks,
> Andrew

Andrew,
are you sure you want just two tables?  Can two people attend the same
event?  If so, you need [Person]--[Attends]--[Event].  So Attends
would be something like (PersonID, EventID) with *both* as primary
key.  Then if you wanted to have all the events a person is attending
in a listbox and move them back and forth, say between lbxAttending
and lbxNotAttending, you could use the .AddItem, and .RemoveItem
methods of the listbox (assumes 2002 or later).  Then if you wanted to
use the selected items in a query, there's code right here...
(it's on www.mvps.org/access somewhere...
right here:
http://www.mvps.org/access/forms/frm0007.htm

basic format of your form
lbxUnselected  (one button for add, one for remove) lbxSelected

then use the code from the link to work with your query.

HTH,
Pieter
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.