Trying to use ME correctly (1 Viewer)

homer2002

Registered User.
Local time
Today, 06:55
Joined
Aug 27, 2002
Messages
152
I have a module that I am using.. to cut a long story short, I need to be able to reference the form that calls the module.

i.e.

I have a form (ME)


the form calls DoSomthing()

I want the DoSomthing() function to change the caption of a label

I figured the code in the module would go somthing like this.

private function DoSomthing()
Forms!Me!lblMyLabel.Caption = "Hello, world"
end function

---- But of course it didn't work. Can anyone tell me how to reference this correctly, cheers.
 

Fuga

Registered User.
Local time
Today, 07:55
Joined
Feb 28, 2002
Messages
566
Maybe like this:

Me.lblmylabel.caption = "hello world"

or maybe like this:

forms!yourformname.lblmylabel.caption "hello world"


Fuga.
 

Mile-O

Back once again...
Local time
Today, 06:55
Joined
Dec 10, 2002
Messages
11,316
Me is a reference to the form or class that can only be used within its module.

You can pass like this:


Code:
Dim vTest As Variant
vTest = DoSomething(Me.Name)


and in the module:

Code:
Public Function DoSomething(ByVal strForm As String) 
    Forms(strForm).lblMyLabel.Caption = "Hello, world" 
End Function
 

namliam

The Mailman - AWF VIP
Local time
Today, 07:55
Joined
Aug 11, 2003
Messages
11,695
Me = the form

private function DoSomthing()
Me.lblMyLabel.Caption = "Hello, world"
end function

Will do the trick directly, but read the link Mile gave anyway...

Regards
 

Mile-O

Back once again...
Local time
Today, 06:55
Joined
Dec 10, 2002
Messages
11,316
homer2002 said:
I have a module that I am using.. to cut a long story short, I need to be able to reference the form that calls the module.


It never really sais if the function was in the form's class module or a standalone module.
 
Last edited:

Users who are viewing this thread

Top Bottom