ONCLICK: Using the CLICKED ITEM as INPUT for a Query ???

  • Thread starter kev100 via AccessMonster.com
  • Start date
K

kev100 via AccessMonster.com

Have been using the OnClick feature recently for the first time....really
cool item.

I have a form which displays a info from a query in datasheet form.

The form is simply a list of name and phone numbers called on a certain day.

When the form is opened, the user inputs the date, and the list comes up.

There is another query that will display any call made to a particular phone
number. The user enters the phone number and all the calls that have ever
been made to that number a displayed.

It would be GREAT if, when the former is run (numbers called on a certain
date)...the user could simply CLICK a phone number and that number be used as
the Input for the latter query (the one that shows any call made to a number
at any time).

I've got the OnClick working to call that other query...I just don't know how
to get it to automatically enter the clicked number into that query's prompt.

Any advice appreciated.
THANKS
 
N

Nikos Yannacopoulos

Kev,

Once an item is in a listbox is clicked, it is also selected;
consequently, what you have to do in the query is drop the prompt for
user input altogether, and make the query criterion read the selected
value of the listbox on the form instead. To do that, change the query
criterion to:

Forms!YourFomrNameHere!YourListBoxNameHere

and you're done.

HTH,
Nikos
 
K

kev100 via AccessMonster.com

Super Cool !

That works great!


If 2 different forms have this feature (which point back to the same query)...
is it possible to adjust the criteria to accept the data from either form?

Something like:


"(Forms!FORM_1!PHONE) or (Forms!FORM_2!PHONE) ?"


....or...is there some wildcard that can be used in the query....etc?

Thanks Very Much!
 
K

kev100 via AccessMonster.com

I tried:

IIf([Forms]![FORM_1]![NUMBER]<>"", [Forms]![ALL_MULTI]![ROUTE], [Forms]!
[FORM_2]![ROUTE])

....for the criteria of the query that is being called....but all it did was
to prompt the user for other Forms' Phone value.


It would be great if some "All purpose" query was possible. That way,
several forms could reference that one query just by a click.

Thanks very much....
 
N

Nikos Yannacopoulos

Kev,

To set the record straight, it's the query that references the form(s),
not the other way around.

Now, if you want your query to be able to pick up its criteria from two
(or more) different forms, then you'd have to use a function in VBA code
which would check to see which form is open, and return the control
value from that form... doable, though not necessarily neat. Any chance
the two forms are similar, so you could use one form instead of two, and
apply whatever difference through code upon opening the form?

HTH,
Nikos
 
K

kev100 via AccessMonster.com

Nikos,

Yes...they indeed are. I gave that a try and it did work, in this instance.
The function for which I had 2 forms was able to be combined into 1 command
that enabled 1 of the the forms to be dual-purpose.


While here may not be the time....I can see where that VBA code could come
very handy in other areas of this project.

Thanks very much for the help...getting this clickable function working makes
a huge difference in these forms.

- Kev
 

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