Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Name Passed to Module

Status
Not open for further replies.

bbrendan

IS-IT--Management
Dec 13, 2001
109
GB
Hi Im just a little stumped.

how can a pass a form name to a module?

for example:

at present that has the form name hard coded like:

frmorders.fOptBegins.Value

But Becuase I want to use the same module on a different form how can I make "frmOrders" a variable of which ever form it was called from

ie:
frm.fOptBegins.Value

thanks


 
Hi Im just a little stumped.
how can a pass a form name to a module? for example:
at present that has the form name hard coded like:
frmorders.fOptBegins.Value
But Becuase I want to use the same module on a different form how can I make "frmOrders" a variable of which ever form it was called from
ie:
frm.fOptBegins.Value

Hi,

Change your module to accept a form as a parameter and pass in the form that you want eg.
Code:
public sub ProcessForm(byval frm as Form)
   <do your stuff here>
end sub

Call it like this: ProcessForm(frmorders)

Regards,

Patrick
 
In the argument list you can pass a reference to the calling form and pick up its Name property. You can also reference a control on the form, either by referencing it through the form or by passing it directly. For example
[tt]
Public Sub mySub ( frm As Form, ctl As Object )

' Get the form name
Dim fname As String
fname = frm.Name
' Reference a control on the form
Dim y As Variant
y = frm.fOptButton.Value
' Reference a passed control
Dim z As Variant
z = ctl.Value
End Sub
[/tt]
and call it with
[tt]
Call mySub Me, fOptButton
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top