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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Public Function

Status
Not open for further replies.

theConjurian

IS-IT--Management
May 4, 2002
35
CA
In a post in October, 2001, MangroBongacello wrote ...

First make the event procedure you want to call public (replace the word Private with Public).

Then in your general module write:

dim x as New Form_YourFormName
x.cmdOpen_Click

I have been trying to apply this to a project I am working on, and seem to be missing something. The form that contains the procedure that I want to run is called Event Details (2 words with a space in between). I just can't seem to get the syntax right for the dim statement.

Dim eventForm As New Form_Event Details

If I understand this correctly, when I execute

eventForm.calculateTotalFee

in form A, the function in form B (Event Details) will fire and apply itself to that form (form B)?

Thanks
 
Any time there is space in a name you can surround it with brackets. [Event Details]
In this case probably [Form_Event Details] is what you need.

I would take a little time and get rid of spaces in the names. The value of having spaces, if any, is not worth the hassle.

If you create a new instance of an object it will have its own properties including events.
 
I thought that I had tried that!

Anyway ... thanks alot. It worked like it should.
 
beyond the immediate (and resolved?) issue, the process is un-necessary. Two (seperate and different) thoughts.

1)[tab]You can reference the procedures of a FORM simply by prefixing the procedure name to the function. However, you need to be sure the foregin forms' procedure does NOT reference the (parent) form, but receieves all of its information through the argument list, which brings ip the next 'thought'

1)[tab]If any procedure is used in more than one instance, it should be placed in a general module and called as necessary. Leaving 'real' code in forms modules is generally 'bad'. I attempt to place all 'real' procedures in general modules and call them from the (Unreal?) code of the forms / reports modules, as in (a REALLY simplistic example):

Public Function FooBar(Abc as String, Defg as String) as String

FooBar = Trim(Abc) & Trim(Defg)

End Function

where the Form may include [txtFoo] and [txtBar] as well as [txtFooBar] and have something like:

Private Sub txtFoo_AfterUpdate()
[tab]txtFooBar = FooBar(Me.txtFoo, Me.txtBar)
End Sub

Private Sub txtBar_AfterUpdate()
[tab]txtFooBar = FooBar(Me.txtFoo, Me.txtBar)
End Sub


In this approach, the FUCTION FooBar can be used to update any text box to either any single string (by sending an empty string as one of the arguments) or to the concatenation of any two strings.


MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top