• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 390
  • Last Modified:

vba function parameters - can form object references be used?

I never see this done, but it seems to work ok.  Any reason why I shouldn't use form object references for parameters in a function?

Of the two statements below, are one better than the other?  If so, why?

Call runReport(2, Forms!frmGetPrinDueDate!cboAdmins, Forms!frmGetPrinDueDate!BDate, Forms!frmGetPrinDueDate!EDate)
-OR-
Call runReport(2, admin, beginDt, endD)

Thanks,
Lynn
0
Lambel
Asked:
Lambel
1 Solution
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
No problem whatsoever. It's done all the time.

mx
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Just a note.  If frmGetPrinDueDate is the form you are running this from, then you can do this:

Call runReport(2, Me.cboAdmins, Me.BDate, Me.EDate)

mx
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
"form object references for parameters "
But you are not really passing the Form Object ... you are passing actual values ... and I assume that is your intent ?

mx
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
Rey Obrero (Capricorn1)Commented:
if you are calling the function/sub runreport() from form "frmGetPrinDueDate"

this is enough

Call runReport(2, admin, beginDt, endD)

if you are calling the function/sub runreport() other that what was stated above you will need to specify where the source of the parameters are

Call runReport(2, Forms!frmGetPrinDueDate!cboAdmins, Forms!frmGetPrinDueDate!BDate, Forms!frmGetPrinDueDate!EDate)
0
 
Dale FyeCommented:
But you could also pass a reference to a form

Call RunReport(2, me)

Public Sub RunReport(SomeNumber as long, frm as Form)

    debug.print frm.cboAdmins, frm.BDate, frm.EDate

End Sub

0
 
LambelAuthor Commented:
DatabaseMX: Yes, that was my intent.  I guess I just never noticed it done this way.  thanks!
Lynn
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now