473,396 Members | 1,714 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,396 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 5327
"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: 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: 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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.