Passing value to Query Criteria from a ListBox

A

Atif

I am using Access 2007.

Presently I am using a Command Button to call a Macro which opens a Query in
Pivot Chart view.

Now I want to use a ListBox which has these options NAE, NAW and EU. How can
I pass selected option from listbox to query so that it only show the
specific region data i.e. NAE or NAW or EU.
 
A

Atif

Thanks:

I am using following criteria
=[Forms]![Switchboard]![ListSalesRegion.Column(0)]
it give error:
Microsoft Office Access database engin does to recognized
=[Forms]![Switchboard]![ListSalesRegion.Column(0)] as a vlid filed name or
expression

plz advise
 
B

bhicks11 via AccessMonster.com

The switchboard is doing some background stuff from a table. I wouldn't run
it off the switchboard, I'd open a little form with the selection.

Try that with this:

forms!switchboard.ListSalesRegion.Column(0)

Bonnie
http://www.dataplus-svc.com
Thanks:

I am using following criteria
=[Forms]![Switchboard]![ListSalesRegion.Column(0)]
it give error:
Microsoft Office Access database engin does to recognized
=[Forms]![Switchboard]![ListSalesRegion.Column(0)] as a vlid filed name or
expression

plz advise
Make the criteria for that field equal to the listbox.
[quoted text clipped - 13 lines]
 
A

Atif

Hi:

My form name is Switchboard. Why Query Criteria not able to recognized the
Listbox. I believe some syntex error. keep in mind i am using Access 2007.

Thanks

bhicks11 via AccessMonster.com said:
The switchboard is doing some background stuff from a table. I wouldn't run
it off the switchboard, I'd open a little form with the selection.

Try that with this:

forms!switchboard.ListSalesRegion.Column(0)

Bonnie
http://www.dataplus-svc.com
Thanks:

I am using following criteria
=[Forms]![Switchboard]![ListSalesRegion.Column(0)]
it give error:
Microsoft Office Access database engin does to recognized
=[Forms]![Switchboard]![ListSalesRegion.Column(0)] as a vlid filed name or
expression

plz advise
Make the criteria for that field equal to the listbox.
[quoted text clipped - 13 lines]
I pass selected option from listbox to query so that it only show the
specific region data i.e. NAE or NAW or EU.
 
B

bhicks11 via AccessMonster.com

Before I go any further - did you create a form yourself and name it
switchboard or are you talking about the switchboard the system creates.

Bonnie
http://www.dataplus-svc.com
Hi:

My form name is Switchboard. Why Query Criteria not able to recognized the
Listbox. I believe some syntex error. keep in mind i am using Access 2007.

Thanks
The switchboard is doing some background stuff from a table. I wouldn't run
it off the switchboard, I'd open a little form with the selection.
[quoted text clipped - 22 lines]
 
A

Atif

Yes I created myself and named it as Switchboard

Atif

bhicks11 via AccessMonster.com said:
Before I go any further - did you create a form yourself and name it
switchboard or are you talking about the switchboard the system creates.

Bonnie
http://www.dataplus-svc.com
Hi:

My form name is Switchboard. Why Query Criteria not able to recognized the
Listbox. I believe some syntex error. keep in mind i am using Access 2007.

Thanks
The switchboard is doing some background stuff from a table. I wouldn't run
it off the switchboard, I'd open a little form with the selection.
[quoted text clipped - 22 lines]
I pass selected option from listbox to query so that it only show the
specific region data i.e. NAE or NAW or EU.
 
A

Atif

I also tried:
=[Forms]![Menu].[List28]

the result the same, Not able to recogniazed as valid field name or expression

Atif said:
Yes I created myself and named it as Switchboard

Atif

bhicks11 via AccessMonster.com said:
Before I go any further - did you create a form yourself and name it
switchboard or are you talking about the switchboard the system creates.

Bonnie
http://www.dataplus-svc.com
Hi:

My form name is Switchboard. Why Query Criteria not able to recognized the
Listbox. I believe some syntex error. keep in mind i am using Access 2007.

Thanks

The switchboard is doing some background stuff from a table. I wouldn't run
it off the switchboard, I'd open a little form with the selection.
[quoted text clipped - 22 lines]
I pass selected option from listbox to query so that it only show the
specific region data i.e. NAE or NAW or EU.
 
M

Michel Walsh

A list box has no 'value', it just has lot of rows (selected or not), and
lot of columns. A text control, or a combo box do have a (one) value, not a
list box.


Vanderghast, Access MVP.
 
A

Atif

Hi Bonnie:
I changed the Form Name as "Menu" the result is same :(

Hi Michel:

I assiged the Listbox value to a text box;
List box Clic event code:

Private Sub List82_Click()
Text86.Value = List82.Column(0)
DoCmd.OpenQuery "SalesGroupManager", acViewPivotChart
End Sub

expression in Query Critaria is:
[Forms]![Text86].[Value]

the error is same " engin does not recognize [Forms]![Text86].[Value] as
Valid Field or Expression.

Atif

bhicks11 via AccessMonster.com said:
You need to not use the name Switchboard - the system uses it.

Bonnie
http://www.dataplus-svc.com
I also tried:
=[Forms]![Menu].[List28]

the result the same, Not able to recogniazed as valid field name or expression
Yes I created myself and named it as Switchboard
[quoted text clipped - 18 lines]
I pass selected option from listbox to query so that it only show the
specific region data i.e. NAE or NAW or EU.
 
B

bhicks11 via AccessMonster.com

Try:

Forms!formname.Text86 = Forms!formname.list82.column(0)

By the way - I wouldn't use the word MENU either.

Bonnie
http://www.dataplus-svc.com
Hi Bonnie:
I changed the Form Name as "Menu" the result is same :(

Hi Michel:

I assiged the Listbox value to a text box;
List box Clic event code:

Private Sub List82_Click()
Text86.Value = List82.Column(0)
DoCmd.OpenQuery "SalesGroupManager", acViewPivotChart
End Sub

expression in Query Critaria is:
[Forms]![Text86].[Value]

the error is same " engin does not recognize [Forms]![Text86].[Value] as
Valid Field or Expression.

Atif
You need to not use the name Switchboard - the system uses it.
[quoted text clipped - 11 lines]
 
A

Atif

Thanks alot for the help.

actually it was not a Syntex problem, I was running a Select Query based on
two Crosstab queries. Now I have changed crosstab queries to select and
everything working fine.

Michel:

we can use listbox to passvalues to a Query
[Forms]![Main]![GrpMgrNo]
GrpMgrNo is a ListBox.

thanks

Atif said:
Hi Bonnie:
I changed the Form Name as "Menu" the result is same :(

Hi Michel:

I assiged the Listbox value to a text box;
List box Clic event code:

Private Sub List82_Click()
Text86.Value = List82.Column(0)
DoCmd.OpenQuery "SalesGroupManager", acViewPivotChart
End Sub

expression in Query Critaria is:
[Forms]![Text86].[Value]

the error is same " engin does not recognize [Forms]![Text86].[Value] as
Valid Field or Expression.

Atif

bhicks11 via AccessMonster.com said:
You need to not use the name Switchboard - the system uses it.

Bonnie
http://www.dataplus-svc.com
I also tried:
=[Forms]![Menu].[List28]

the result the same, Not able to recogniazed as valid field name or expression

Yes I created myself and named it as Switchboard

[quoted text clipped - 18 lines]
I pass selected option from listbox to query so that it only show the
specific region data i.e. NAE or NAW or EU.
 
B

bhicks11 via AccessMonster.com

Glad to hear you have found a solution!

Bonnie
http://www.dataplus-svc.com
Thanks alot for the help.

actually it was not a Syntex problem, I was running a Select Query based on
two Crosstab queries. Now I have changed crosstab queries to select and
everything working fine.

Michel:

we can use listbox to passvalues to a Query
[Forms]![Main]![GrpMgrNo]
GrpMgrNo is a ListBox.

thanks
Hi Bonnie:
I changed the Form Name as "Menu" the result is same :(
[quoted text clipped - 32 lines]
 

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