How to pass a form to a custom function

  • Thread starter Thread starter Bill R via AccessMonster.com
  • Start date Start date
B

Bill R via AccessMonster.com

Rather than passing several arguments from the data in a form to a function,
it would be much simpler for me to pass the entire form. Something like:

function MyFunction (frm as Form) as string

First of all, will this function work as is?
Second, what would the variable look like that is passed to the function?
Would it be:

strString = MyFunction([Forms]!frmMyForm)

Thanks,

Bill
 
Bill R via AccessMonster.com wrote in message
Rather than passing several arguments from the data in a form to a function,
it would be much simpler for me to pass the entire form. Something like:

function MyFunction (frm as Form) as string

First of all, will this function work as is?
Second, what would the variable look like that is passed to the function?
Would it be:

strString = MyFunction([Forms]!frmMyForm)

Thanks,

Bill

If you're passing the current form

strString = MyFunction(Me)
 
Bill said:
Rather than passing several arguments from the data in a form to a function,
it would be much simpler for me to pass the entire form. Something like:

function MyFunction (frm as Form) as string

First of all, will this function work as is?

Yup! I do this all the time. Well, not all the time, really, only where
necessary. :-)
Second, what would the variable look like that is passed to the function?
Would it be:

strString = MyFunction([Forms]!frmMyForm)

Absolutely! An alternative would be Forms("frmMyForm") which is nicer
because you can use a variable instead of the literal string.
 
Yes. One the object is passed then its just a matter of referecing (had
a pint jist now) as in....

frm.name, etc.

I would put a STOP statement into MyFunction, call it and then play
around with the object in the Immediate Window. Try the following
commands...

?frm.name
?frm.recordSource
?frm.caption
?frm.controls.count

David H
 
Back
Top