473,387 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to utilise "Me" in a public function

A2003, XP Pro.

I have a VBA routine that I use to record data transactions in a history
table. I'd like to use this routine for every form in my app by putting it
in a public function and calling it from each form. Trouble is, the code
uses the "Me" keyword throughout to refer to data objects and I can't quite
fathom out how to pass it to my function and how to handle it once it's
there.

Any pointers?

Many thanks.
Keith.
Nov 13 '05 #1
4 5324
"Keith" <ke*********@baeAWAYWITHITsystems.com> wrote in message
news:42**********@glkas0286.greenlnk.net...
A2003, XP Pro.

I have a VBA routine that I use to record data transactions in a history
table. I'd like to use this routine for every form in my app by putting
it in a public function and calling it from each form. Trouble is, the
code uses the "Me" keyword throughout to refer to data objects and I can't
quite fathom out how to pass it to my function and how to handle it once
it's there.

Doesn't matter, sussed it. If anyone's interested, you pass the "Me"
keyword to a "Form" object in the function. Hope that makes sense :o)
Nov 13 '05 #2
MLH
You could pass the formname to the function on each call.
I realize that would mean modifying the call to your public
procedure on each and every form that calls it, but its sure
to work.
Nov 13 '05 #3
MLH <CR**@NorthState.net> wrote in
news:ur********************************@4ax.com:
You could pass the formname to the function on each call.
I realize that would mean modifying the call to your public
procedure on each and every form that calls it, but its sure
to work.


That's not the best solution, as you'd then have to look up the form
in the forms collection.

The best solution is to pass a form reference as a parameter of your
subroutine:

Public Sub DoSomething(frm As Form)
Set frm.Visible = True
[etc.]
End Sub

And you'd call it in any form like this:

Call DoSomething(Me)

That passes (By Reference) a pointer to the original form instance.
Passing the name would then require a lookup, and that's
inefficient.

Also, doing it with passing the form reference means that "Me" in
your subroutine can simply be replaced with "frm", whereas you'd
still have to set up some kind of object within the subroutine if
passing the form name (though you could do a WITH block, if it
worked for the code you had there).

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #4
"David W. Fenton" <dX********@bway.net.invalid> wrote in message
news:Xn**********************************@24.168.1 28.90...

The best solution is to pass a form reference as a parameter of your
subroutine:

Public Sub DoSomething(frm As Form)
Set frm.Visible = True
[etc.]
End Sub

And you'd call it in any form like this:

Call DoSomething(Me)

That's exactly what I have done David, I managed to suss it out about an
hour after the OP.
Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: John Baker | last post by:
HI: I see the term "Me!" in a lot of Access statements, bit don't quite know what it means. In the same contexts as wondering what the meaning if "is" is, I wonder what the meaning of "Me!" is....
1
by: RC | last post by:
If I want to explicitly save the record before executing a Close action. Which of the following should I use? Or does it depend on whether it is based on a Form or something else? If Me.Dirty...
1
by: RzB | last post by:
In a previous post in this NG (Oct 98) http://makeashorterlink.com/?D505347FB Henry Craven says that he was investigating a relationship between the presence or absence of a "Me!" prefix, the...
5
by: Agnes | last post by:
For my own practices. I like to put "Me". e.g IF Me.txtInvoice.textlength = 0 ....... etc Me.txt.....etc However, Is there any difference (without Me) ?? Thanks
14
by: Richard Thornley | last post by:
Hello, I realize that this is a very basic question but is there an advantage to using Me.ControlName.Text over just using ControlName.Text? I have been leaving the Me. off but would include it...
6
by: John | last post by:
Hi, Maybe someone can explain the use of "Me" to me? The example class CPoint3 uses the Me reference in the output statement: Console.WriteLine("CPoint3 constructor: {0}", Me) The text states:...
4
by: darrell | last post by:
I recently wrote a program in Access VBA that contains this snippet of code: For i = 1 to TotalBanks With Me("txtBank" & Chr(i + 64)) .BackColor = vbBlue .ForeColor = vbWhite End With Next i...
24
by: M O J O | last post by:
Hi, Instead of doing this.... Public Class Form1 Public Shared Sub CreateAndShow() Dim f As New Form1 f.Show() End Sub
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.