Connecting Tech Pros Worldwide Help | Site Map

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

  #1  
Old November 13th, 2005, 05:04 AM
Andrew
Guest
 
Posts: n/a
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
  #2  
Old November 13th, 2005, 05:04 AM
Mal Reeve
Guest
 
Posts: n/a

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


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.



"Andrew" <spidrw@gnt.net> wrote in message
news:d8c667d9.0411020921.3c5da36c@posting.google.c om...[color=blue]
> 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[/color]


  #3  
Old November 13th, 2005, 05:05 AM
Andrew
Guest
 
Posts: n/a

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


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


"Mal Reeve" <lorimal@earthlink.net> wrote in message news:<5_Thd.17419$ta5.6906@newsread3.news.atl.eart hlink.net>...[color=blue]
> 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.
>
>
>[/color]
  #4  
Old November 13th, 2005, 05:05 AM
Mal Reeve
Guest
 
Posts: n/a

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


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.

"Andrew" <spidrw@gnt.net> wrote in message
news:d8c667d9.0411030649.6a4816c5@posting.google.c om...[color=blue]
> 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
>
>
> "Mal Reeve" <lorimal@earthlink.net> wrote in message
> news:<5_Thd.17419$ta5.6906@newsread3.news.atl.eart hlink.net>...[color=green]
>> 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.
>>
>>
>>[/color][/color]


  #5  
Old November 13th, 2005, 05:05 AM
Mal Reeve
Guest
 
Posts: n/a

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


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.

"Andrew" <spidrw@gnt.net> wrote in message
news:d8c667d9.0411030649.6a4816c5@posting.google.c om...[color=blue]
> 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
>
>
> "Mal Reeve" <lorimal@earthlink.net> wrote in message
> news:<5_Thd.17419$ta5.6906@newsread3.news.atl.eart hlink.net>...[color=green]
>> 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.
>>
>>
>>[/color][/color]


  #6  
Old November 13th, 2005, 05:06 AM
Pieter Linden
Guest
 
Posts: n/a

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


spidrw@gnt.net (Andrew) wrote in message news:<d8c667d9.0411020921.3c5da36c@posting.google. com>...[color=blue]
> 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[/color]


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
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi-Select List Box 3075 Syntax Error trose178@gmail.com answers 17 July 22nd, 2008 02:05 PM
Combo dropdown list box (on Switchboard)-How to open a specific row? Cagey answers 3 August 3rd, 2006 04:25 AM
How do I pass the value from a list box into a query? Jelena answers 1 November 13th, 2005 05:06 AM
Code for Filtering from Mult-select List Box Criteria William Wisnieski answers 19 November 12th, 2005 06:24 PM