Use Combobox column in Query

R

Ripper

I am attempting to use the column property of a combo box in a filter without
success. I use the following in the criteria of a name field...

BETWEEN [forms].[frmMainAdmin-Alpha].[lstFilter].[Column1] AND
[forms].[frmMainAdmin-Alpha].[lstFilter].[Column2]

The combo box has 3 fields: AlphaTitle (the title of the record), AlphaStart
(A text field with the value of "A*", and AlphaEnd (A text field with the
value of "Kz*")



It keeps asking me for the parameter values of columns 1 and 2. What am I
doing wrong?
 
D

Duane Hookom

One solution is to add an invisible text box to your form with a control
source like:
=lstFilter.Column(1)
Then use the text box in your query criteria.
 
R

Ripper

Works perfect. Thanks Duane. Kinda feels like cheating though.
--
Thanks As Always
Rip


Duane Hookom said:
One solution is to add an invisible text box to your form with a control
source like:
=lstFilter.Column(1)
Then use the text box in your query criteria.

--
Duane Hookom
Microsoft Access MVP


Ripper said:
I am attempting to use the column property of a combo box in a filter without
success. I use the following in the criteria of a name field...

BETWEEN [forms].[frmMainAdmin-Alpha].[lstFilter].[Column1] AND
[forms].[frmMainAdmin-Alpha].[lstFilter].[Column2]

The combo box has 3 fields: AlphaTitle (the title of the record), AlphaStart
(A text field with the value of "A*", and AlphaEnd (A text field with the
value of "Kz*")



It keeps asking me for the parameter values of columns 1 and 2. What am I
doing wrong?
 
D

Duane Hookom

You could also try wrap the Forms!frm...!cboYours.Column(1) inside Eval()

BETWEEN Eval([forms].[frmMainAdmin-Alpha].[lstFilter].Column(1)) AND
Eval([forms].[frmMainAdmin-Alpha].[lstFilter].Column(2))

--
Duane Hookom
Microsoft Access MVP


Ripper said:
Works perfect. Thanks Duane. Kinda feels like cheating though.
--
Thanks As Always
Rip


Duane Hookom said:
One solution is to add an invisible text box to your form with a control
source like:
=lstFilter.Column(1)
Then use the text box in your query criteria.

--
Duane Hookom
Microsoft Access MVP


Ripper said:
I am attempting to use the column property of a combo box in a filter without
success. I use the following in the criteria of a name field...

BETWEEN [forms].[frmMainAdmin-Alpha].[lstFilter].[Column1] AND
[forms].[frmMainAdmin-Alpha].[lstFilter].[Column2]

The combo box has 3 fields: AlphaTitle (the title of the record), AlphaStart
(A text field with the value of "A*", and AlphaEnd (A text field with the
value of "Kz*")



It keeps asking me for the parameter values of columns 1 and 2. What am I
doing wrong?
 
K

Ken Snell [MVP]

Ripper said:
Works perfect. Thanks Duane. Kinda feels like cheating though.

It's not cheating. You cannot reference the Column property of a listbox or
combobox from a query. So Duane's method is the right way to do it.

Alternatively, you can use a public function that reads the Column property
from the combobox, and use that function in your query to return the value
to the query.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top