use of "me" keyword

C

Chip Orange

I'd like to add a subroutine in our global library add-in, in the code
modules, which can be called as part of anyone (of our programmers) form's
initialize event. This routine uses the keyword "me." to reference the
current form, but the compiler won't allow me to use it in code in a
standard code module (I guess it's only allowed in forms modules).

Anyone have any way around this?

thanks.

Chip
 
J

Jezebel

You need to pass an argument to the function to use in its place, such as a
reference to the form or class module that would otherwise be the 'me'.
 
M

Malcolm Smith

Chip

Bear in mind that 'Me' is a special pointer which points to the current
form container (in much the same was as ActiveDocument is a pointer which
points to the active document).

Therefore, if you want to move the code to a module then change the 'Me'
pointer to the pointer of the form.

So, if you have a form called clsMainForm and you define it in your code
as:

Dim oForm as clsMainForm


set oForm = New clsMainForm

then in your code you can access the contents, ie the controls of the
clsMainForm by your oForm pointer, thus:

sDate = oForm.txtDeliveryDate.Text

rather than

sDate = Me.txtDeliveryDate.Text


Does this help?

- Malc
www.dragondrop.com
 
C

Chip Orange

thanks, I always appreciate the info and responses, but I wrote a routine to
add/display horiz and vert scrollbars as needed, and it was meant to run
against whatever form was currently being displayed (and I wouldn't know the
name of it).

Someone else mentioned I could call the routine, and pass "me" as an
argument, so I'll try that.

thanks to all, this is really a great group of folks.

Chip
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top