473,698 Members | 2,181 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing the Me Keyword to a Public Function

A97, NT4.

I've seen an example of this posted here but I can't for the life of me
find it. If I have a lot of controls on a form which all require the same
After Update action, what syntax do you need to pass "Me" to the public
function in a module?

I've tried calling

Public Function libComboFilter( frmForm As Form_Form1) As String

libComboFilter = frmForm.Name
Debug.Print libComboFilter

End Function

from a form called "Form1" with

libComboFilter (Me)

but I get a type mismatch error. I've nothing specific to achieve, I'm just
trying to get the principle right.

Thanks.
Keith.
Nov 13 '05 #1
15 12555
Keith,
are you fishing for Me.ActiveContro l? I would think you'd have to
assign that to a variable in your form's code module and then pass the
variable to your function... Something like

Dim strCtrlName as string
Dim strFormName as string
strFormName=me. name
strCtrlName = me.activecontro l.name

X=fSomePublicFu nction(strFormN ame,strCtrlName )

then it's totally unambiguous.

Nov 13 '05 #2
pi********@hotm ail.com wrote:
Keith,
are you fishing for Me.ActiveContro l? I would think you'd have to
assign that to a variable in your form's code module and then pass the
variable to your function... Something like

Dim strCtrlName as string
Dim strFormName as string
strFormName=me. name
strCtrlName = me.activecontro l.name

X=fSomePublicFu nction(strFormN ame,strCtrlName )

then it's totally unambiguous.


Well I could make it work like that but I could have sworn I saw some code
on here where the Me keyword was passed on it's own ... maybe I was
mistaken.

Many thanks for a speedy response.

Keith.
Nov 13 '05 #3
Try this:

Public Function MyFunction(frmO bject)
MyFunction = frmObject.Name
End Function
Call it this way:
MyName = MyFunction(Me)
--

Ken Snell
<MS ACCESS MVP>

"Keith" <ke*********@Aw ayWithYerCrap.c om> wrote in message
news:Xn******** *************** *@10.15.188.42. ..
A97, NT4.

I've seen an example of this posted here but I can't for the life of me
find it. If I have a lot of controls on a form which all require the same
After Update action, what syntax do you need to pass "Me" to the public
function in a module?

I've tried calling

Public Function libComboFilter( frmForm As Form_Form1) As String

libComboFilter = frmForm.Name
Debug.Print libComboFilter

End Function

from a form called "Form1" with

libComboFilter (Me)

but I get a type mismatch error. I've nothing specific to achieve, I'm
just
trying to get the principle right.

Thanks.
Keith.

Nov 13 '05 #4
Either
call libComboFilter( Me)

Or
libComboFilter Me

should work, although why you would use a public function for this when the
parameter type you are passing is Form_Form1 I don't know.

I would expect you to either have

Public Function libComboFilter( frmForm As Form) As String

or put the function in the form class module in which case you don't need to
pass a parameter.
--
Terry Kreft
MVP Microsoft Access
"Keith" <ke*********@Aw ayWithYerCrap.c om> wrote in message
news:Xn******** *************** *@10.15.188.42. ..
A97, NT4.

I've seen an example of this posted here but I can't for the life of me
find it. If I have a lot of controls on a form which all require the same
After Update action, what syntax do you need to pass "Me" to the public
function in a module?

I've tried calling

Public Function libComboFilter( frmForm As Form_Form1) As String

libComboFilter = frmForm.Name
Debug.Print libComboFilter

End Function

from a form called "Form1" with

libComboFilter (Me)

but I get a type mismatch error. I've nothing specific to achieve, I'm just trying to get the principle right.

Thanks.
Keith.

Nov 13 '05 #5
I've been using this approach for years:

How to call a function and pass your form

Me.HelpLabel.Ca ption = "How is it going"

SomeFunction(Me )
-------------------------------------

Public sub SomeFunction(Ca lling as form)

Calling.HelpLab el.Caption = "Going really good"

Exit Sub

Hank Reed

Nov 13 '05 #6
Keith wrote:
A97, NT4.

I've seen an example of this posted here but I can't for the life of me
find it. If I have a lot of controls on a form which all require the same
After Update action, what syntax do you need to pass "Me" to the public
function in a module?

I've tried calling

Public Function libComboFilter( frmForm As Form_Form1) As String

libComboFilter = frmForm.Name
Debug.Print libComboFilter

End Function

from a form called "Form1" with

libComboFilter (Me)

but I get a type mismatch error. I've nothing specific to achieve, I'm just
trying to get the principle right.

Thanks.
Keith.


Should be:

Public Function libComboFilter( frmForm As Access.Form) As String


--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Nov 13 '05 #7
"Ken Snell" <kt***********@ ncoomcastt.rena etl> wrote:
Public Function MyFunction(frmO bject)
MyFunction = frmObject.Name
End Function
Call it this way:
MyName = MyFunction(Me)


That's it, many thanks indeed Ken. Thanks also to all other respondees.

Keith.
www.keithwilby.com
Nov 13 '05 #8
This is bad practice, if you know the type of the argument your procedure
expects then you should declare the argument as that type, not as a variant
which is what this declaration is doing.

--
Terry Kreft
MVP Microsoft Access
"Grumpy Old Man" <ke*********@Aw ayWithYerCrap.c om> wrote in message
news:Xn******** *************** *@10.15.188.42. ..
"Ken Snell" <kt***********@ ncoomcastt.rena etl> wrote:
Public Function MyFunction(frmO bject)
MyFunction = frmObject.Name
End Function
Call it this way:
MyName = MyFunction(Me)


That's it, many thanks indeed Ken. Thanks also to all other respondees.

Keith.
www.keithwilby.com

Nov 13 '05 #9
"Terry Kreft" <te*********@mp s.co.uk> wrote:
This is bad practice, if you know the type of the argument your
procedure expects then you should declare the argument as that type,
not as a variant which is what this declaration is doing.


You're referring to the omission of "As Form"? I've included that and it
works fine. Thanks for your response Terry, much appreciated.

Regards,
Keith.
Nov 13 '05 #10

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

Similar topics

13
17918
by: Abe Frohnman | last post by:
Hello all, I'm passing a reference to a class into the constructor of a form, like so: public MyForm(int count, ref Area myArea) {...} How can I use myArea outside the constructor? Should I create another Area and assign myArea to it (ie: Area foo = myArea;) or is there a better way? ~AF
3
2203
by: aaa | last post by:
I am having trouble getting a complex data type to get passed to a non-COM dll's function by ref and return back data from that object. Simple data types work fine but when I try the complex data types, with the class it simply initializes but returns nothing. The struct I have tried several different ways all of them either erros or the app simply closes out (usually when I try to pass the struct with the ref keyword). Any help would be...
13
2789
by: Maxim | last post by:
Hi! A have a string variable (which is a reference type). Now I define my Method like that: void MakeFullName(string sNamePrivate) { sNamePrivate+="Gates" }
5
1646
by: blue | last post by:
We often get connection pooling errors saying that there are no available connections in the pool. I think the problem is that we are passing around open readers all over the place. I am planning on changing this in our code and I expect this to fix our problem. We have our connection pooling set to the default number of connections open. We probably have about 3-7 users concurrently using our web site. So, the problem isn't that we...
7
2478
by: DareDevil | last post by:
I have written a method that should modify the folder path passed to it into one that exists and is selected by the user. It then returns a boolean depending on whether a folder path was selected by the user It then dawned on me that I was passing in a readonly property into the method yet neither at compile time or runtime was I getting any kind of error or warning. I tested with a simple string field and it alter the string as expected but...
12
2679
by: Andrew Bullock | last post by:
Hi, I have two classes, A and B, B takes an A as an argument in its constructor: A a1 = new A(); B b = new B(a1);
7
3303
by: TS | last post by:
I was under the assumption that if you pass an object as a param to a method and inside that method this object is changed, the object will stay changed when returned from the method because the object is a reference type? my code is not proving that. I have a web project i created from a web service that is my object: public class ExcelService : SoapHttpClientProtocol {
4
2810
by: Deckarep | last post by:
Hello fellow C# programmers, This question is more about general practice and convention so here goes: I got into a discussion with a co-worker who insisted that as a general practice all objects should be passed by reference using the ref keyword generally speaking because as the writer of code you are conveying your intentions that an Object should/can be modified by your function.
13
3198
by: Andy Baker | last post by:
I am attempting to write a .NET wrapper in C# for an SDK that has been supplied as a .LIB file and a .h header file. I have got most of the functions to work but am really struggling with the functions that require a structure to be passed to them. The function declaration in the .h file is of the form: SDCERR GetConfig(char *name, SDCConfig *cfg); where SDCConfig is a structure defined in the .h file. I am not much of a C (or C#)...
0
8598
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,...
0
9014
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8885
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
8855
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7708
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
6515
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
5857
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
4612
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3037
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.