Passing the selection from a listbox to a querie

  • Thread starter Thread starter Chris Gorham
  • Start date Start date
C

Chris Gorham

Hi,

I'm simply trying to use a listbox to select a date and then punch a button
to run a querie based on the selected date.

The format of the link in the querie to the listbox is
[forms]![Main Menu]![list_box_mnth_sel]![Mnth of Dump]

where "Main Menu" is the name of the form containing the listbox and button
and "list_box_mnth_sel" is the name of the listbox object and "Mnth of Dump"
is the field title of the querie behind the listbox

The listbox populates the date correctly when I open the form and when I
manually put the date into the querie that I want to link, then it runs
happily as well...

What am I doing wrong...?? Thanks...Chris
 
Try to use reference [forms]![Main Menu]![list_box_mnth_sel]. As the query
is run it just looks up for current the value of the listbox and uses it as
criteria. Where the listbox gets the values from is irrelevant.

Regards,

Mika
 
Chris

There's a chance that what the listbox displays and what value(s) it
actually holds are not the same. That would depend on your bound column and
column widths for the listbox.

So you may be telling your query to look for "17" when what you see in the
listbox is "11/12/2007".

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Hi,

I'm simply trying to use a listbox to select a date and then punch a button
to run a querie based on the selected date.

The format of the link in the querie to the listbox is
[forms]![Main Menu]![list_box_mnth_sel]![Mnth of Dump]

where "Main Menu" is the name of the form containing the listbox and button
and "list_box_mnth_sel" is the name of the listbox object and "Mnth of Dump"
is the field title of the querie behind the listbox

The listbox populates the date correctly when I open the form and when I
manually put the date into the querie that I want to link, then it runs
happily as well...

What am I doing wrong...?? Thanks...Chris

Take a look at the column.

Forms![Main Menu]![list_box_mnth_sel].column(2)

I believe the column count starts at 0, so this example would actually
point to the third column.

Hope this helps,
Chris M.
 
Back
Top