How to pass a form to a custom function

  • Thread starter Bill R via AccessMonster.com
  • 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
 
R

RoyVidar

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)
 
B

Bas Cost Budde

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.
 
D

David C. Holley

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top