Read correct value from repeating form from script?

L

Lord-Data

I've developed a form that returns results from a query based upon a search
entered, and would like to have a button next to each result shown, that
will open a report based on that result.

So far i've got it displaying everything fine .. a button next to each
result .. however, in the script for that button, I obviously need to access
the "ID" field as part of that result .. ID.Value returns the first value
found, but clicking the button next to any result always returns the first
result found, which is obviously the Current Record .. is there a way to get
the other value easily based on the click, if the user clicks the button
without changing the CurrentRecord first?

Thanks in advance!

(This is access 97, if it makes any different)
 
R

rowiga

I use a continuous form as a summary form which displays the results of
query. Displaying a report or detail for these records displayed in the
continuous form can be done in a couple of different ways. In my case, since
the form displays o summary of a query, none of the data is really editable
so I use the click event on one of the fields to perform an action based on
the current record such as printing a report or displaying detail. Clicking
on a text field in the record makes it the current record so using that logic
you can open a report where your primary key (ID) in the current record
equals the same primary key value in your table. Such as:

DoCmd.OpenReport "MyReport", acPreview, "",
"[MyTable]![ID]=[Forms]![MyForm]![ID]"

I've also used small rectangles of color within each record that display
next to the data to perform certain actions and include a color coded legend
in the form footer. I apply code to the Click event for the rectangles for
each action. So clicking the red square prints the current record. Clicking
the blue square displays record detail. Clicking the yellow square emails the
record. Clicking on the black square filters records in some manner....etc.
 
Top