Reference form control for a query

H

hamidrjafari

Hi

I know it is easy to reference value of a control on a form in a query.
For example we could use this expression in the WHERE clause of a
simple SQL SELECT query:
[forms]![myLoadedForm]![control]

But i have a problem. It only works for simple 'native' controls such
as textboxes, comboboxes, etc and not for complex ones such as
treeviews and listviews. Actually the thing I want to reference is the
selected item in the treeview and I have used a veriaty of formats:
[forms]![myLoadedForm]![tvw].selectedItem
[forms]![myLoadedForm]![objTvw].selectedItem -- that I had in the
form's load event: set objTvw = tvw.object
....

What should I do?
And also why it is needed to have such statement : set objTvw =
tvw.object?
thnx
hamid
 
D

Douglas J. Steele

Write a function that returns the value you need, and refer to the function,
not the control.
 
Z

zz

Thanks Douglas
It worked.
Write a function that returns the value you need, and refer to the function,
not the control.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi

I know it is easy to reference value of a control on a form in a query.
For example we could use this expression in the WHERE clause of a
simple SQL SELECT query:
[forms]![myLoadedForm]![control]

But i have a problem. It only works for simple 'native' controls such
as textboxes, comboboxes, etc and not for complex ones such as
treeviews and listviews. Actually the thing I want to reference is the
selected item in the treeview and I have used a veriaty of formats:
[forms]![myLoadedForm]![tvw].selectedItem
[forms]![myLoadedForm]![objTvw].selectedItem -- that I had in the
form's load event: set objTvw = tvw.object
...

What should I do?
And also why it is needed to have such statement : set objTvw =
tvw.object?
thnx
hamid
 

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