Passing a reference to a form

  • Thread starter Thread starter Michael Fitzgerald
  • Start date Start date
M

Michael Fitzgerald

I want to be able to pass, to a global function or
procedure, a reference to the form from which the call
was made.

eg.

On form frmTestOne

Call ProcedureX (ref to form)
...
....

ProcedureX( .... )

Code like, for example,

Forms!frmTestOne!cmdExit.enabled = False


Any brilliant suggestions?

Many thanks,
Michael
 
In most form code, in place of the full forms refences..we use me

So,

Call ProceudreX(me)

Should do the trick....
 
-----Original Message-----
In most form code, in place of the full forms refences..we use me

So,

Call ProceudreX(me)

Should do the trick....


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(e-mail address removed)
http://www.attcanada.net/~kallal.msn

Thanks Albert, but how would I set up the header of the
procedure to utilize this reference

i.e ProcedureX( ???? as ???) as ?????
.
Sorry for being thick,

Thanks,
Michael
 
Lets pretend we have a button on a form..and we want to call a module
routine and pass the form.


Private Sub Command2_Click()

Call MyCoolRoutine(me)

End Sub



In a module, the sub would be defined as:

Public Sub MyCoolRoutine(f as form)

' now, we can do anything we want to this form.

f.refresh ' this would write the current record to disk.

f.requery ' this would re-query the form

f.RecordSource = "select * from tblCustomers where City = 'Edmonton'"


msgbox "last name is = " & f!LastName

end if

Anway...you get the idea....
 
Back
Top