Question about 'Me.'

AUGuy

Newly Registered Idiot
Local time
Today, 00:20
Joined
Jul 20, 2010
Messages
135
Is it possiable to have a replaceable paramater in a "me" command. I'm using a loop and am trying to find a way to do Me.variable to change a series of labels on a form. Is this possible? If so, what would be the proper syntax?

Thanks!
Guy
 
Just an FYI - Me is not a command. It is a shortcut reference to the current class object. The most common in Access being a form or report. But it can also refer to a custom class if in the current context.

So, anyway, if you want a variable use:
Code:
Dim strFormName As String
Dim strControlName As String
Forms(strFormName).Controls(strControlName).Value

or you can pass the actual form like this:

Code:
Private Sub Command1_Click()
   MsgBox  MyFunction(Me, Me.cboSomething)
End Sub

and in your function
Code:
Function MyFunction(frm As Form, ctl As Control) As String
     MyFunction = frm.ctl.Value
End Function

Hope that helps.
 
Last edited:
Thanks, Bob. The extra contextual information is always appreciated. Works like a charm. I'm working on a dynamic menu system within a single form based on the user's permission levels. I think its pretty neat. I'll post it when I'm finished to let all of you who're smarter than me tell me how it can be better :)
 

Users who are viewing this thread

Back
Top Bottom