reference form for update variable

K

Ken Smith

I have several similar forms with a common field: GISIndx.

From each of these forms I want to execute a macro that runs a query used to
update a field in a table to equal the GISIndx value.

I want to use the same query without regard to the form that is open, but
unless I am having trouble as the query stops and asks for the input value
that should be picked up from the form.

Is there a generic reference for that variable expression in the update
field of the query that will point to the GISIndx value on the active form
and what does it look like?
 
M

Michel Walsh

Hi,



Use a function in a standard module (not in a form, report or other
class).


Public Function MyParam( ControlName As String ) As Variant
Dim f as Form
f=Screen.ActiveForm
MyParam=f.Controls( ControlName )
End Function


And in the query, use:


SELECT ... WHERE myField = MyParam("Text0")


as example.


Hoping it may help,
Vanderghast, Access MVP
 
Top