Passing value to Query Criteria from a ListBox

  • Thread starter Thread starter Atif
  • Start date Start date
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.
 
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
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
Back
Top