473,774 Members | 2,191 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5364
"Keith" <ke*********@ba eAWAYWITHITsyst ems.com> wrote in message
news:42******** **@glkas0286.gr eenlnk.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**@NorthStat e.net> wrote in
news:ur******** *************** *********@4ax.c om:
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********@bwa y.net.invalid> wrote in message
news:Xn******** *************** ***********@24. 168.128.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
27208
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. Can someone enlighten me? Regards
1
6804
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 Then RunCommand acCmdSaveRecord End If DoCmd.Close or
1
3085
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 value of the Top propery of a control, and the occurrence of an invalid runtime error "The control or subform control is too large for this location"
5
1572
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
10794
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 if there are benefits. Thanks, Richard
6
1673
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: "This implicitely invokes the class's ToString method". This would be clear if Me.ToString was used, which I tested and works too!. Actually, Me.Anything works and gives the same results as long as Anything is a class member.
4
5286
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 The above code was tested and works.
24
2842
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
9621
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10046
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8939
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7463
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6717
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5358
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4014
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.