Query with 'active' form field

kballing

I do stuff
Local time
Today, 11:33
Joined
Nov 17, 2009
Messages
51
I currently have a basic query that uses a form field. This query is used as the row source for a listbox that has a lot of events associated with it.

SELECT *
FROM ITEMS
WHERE ITEMS.ITEM_ID = Forms![Form 1]!ItemID

How can I change this query to work in more than one form, not just Form 1? Is there a way I can reference the active form or the form from where the query is called e.g. WHERE ITEMS.ITEM_ID = Forms![Active Form]!ItemID (assuming all forms have an 'ItemID' field)

More specifically I want to do this:

In Form 1 my listbox rows are the result of the query. When I select a record, some function is called via Before Update.
In Form 2 I want to use the query results in a listbox, only selecting a result performs a different function in that form on some other event.
In Form 3 perhaps the same query can be used to simply display all the records for editing.

None of the forms are linked to any tables and I don't want to use subforms. The only solution I can think of is to make many copies of the query and specify the form to use in each one, but where's the fun in that.;)
 
i don't think there's an easy way to do what exactly you describe.

i wonder if all these functions you describe can actually be put into one form and perhaps use a combo and subforms or something to select items and display related records.

if they are all using a similar data, then they must be somehow related. i have only one form (and one subform) for items in my ordering database, and it does everything i want it to...

what exactly are these downstream processes you are doing with the data. this might actually be quite important for us to know in order to make your DB efficient and easy to use.

see images attached for examples of what i mean. and let me know if i have misunderstood somewhere.
 

Attachments

  • Listbox find records.jpg
    Listbox find records.jpg
    82.1 KB · Views: 239
  • ListboxMultipleFilters.jpg
    ListboxMultipleFilters.jpg
    77.3 KB · Views: 215
  • Items with Order subform.jpg
    Items with Order subform.jpg
    81.8 KB · Views: 218
Thanks for the reply, however, this post sat long enough that I could figure it out on my own. Not exactly sure how to close a post, but consider this one closed.
 
the customary way to "close" as post is to announce the solution that worked for you so that others may benefit - this is normal even if no replies were given.
 

Users who are viewing this thread

Back
Top Bottom