get reference to listbox column value with an update query?

is anybody aware of how to use a list box column as a criteria in a query?

basically i have a list box based on a query, and the 2nd coloumn (column(1)) i want to use as a criteria....this is so i can update a value in another un-opened table. i have tried the following [forms]![frmOrderData]![lstExtensions.column(1)] but i get invalid use of brackets....so i try [forms]![frmorderdata]![lstextensions].[column(1)] and it doesnt reference it....any help would be appreciated

thanks
mrBrightsideAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
This would be the correct way to write it:

  [forms]![frmOrderData]![lstExtensions].column(1)

JimD
0
mrBrightsideAuthor Commented:
thanks but it is giving me error message "undifined function".........im doing it through design view by the way, not sql
0
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
Set it up with a function call.  Open a module in design view and paste in:

Function  ReturnValue() as variant

   ReturnValue =  forms![frmOrderData]![lstExtensions].column(1)

End Function.

 Save the module.  In your query, put:

 =ReturnValue()

  on the criteria line.  And of course the form needs to be open or you'll get an error.

JimD
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Powerful Yet Easy-to-Use Network Monitoring

Identify excessive bandwidth utilization or unexpected application traffic with SolarWinds Bandwidth Analyzer Pack.

mrBrightsideAuthor Commented:
yep, that works, ur very good.....can i just ask though, using modules, does that slow database performance?
0
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
<<does that slow database performance>>

  No, you won't notice the difference at all.  Because the call to the function doesn't have any arguments, Access is smart enough to figure out that it needs to call it once for the entire query.  The call to get the value will only take a fraction of a second.

JimD
0
mrBrightsideAuthor Commented:
brilliant, thanks alot
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.