473,320 Members | 2,083 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,320 software developers and data experts.

Using the Me keyword in a Module

Good afternoon,

I've been batling with this for a very long time. I would like to be able to use the Me keyword in a module. I spent hours and days trying to find a solution for this. There might be one, there might not be one! So before I waste anymore time or just give up, could I PLEASE have an answer for my desperate call!!!

I've got a very simple example to illustrate what I'm looking for so I can adapt it to my project.

I've got a form called Form1.
Inside this form there is a button called cmdCaption.
On click of this button, a function stored in a module will be called. This function is called fncCaption and it does:

Me.Caption="My Form"

I can change the Form name in its properties, but that's not how I want it.
I can create a table to lookup the Form name and change it for me, but that's not how I want it.
I could pass the form name to the module, but that's not how I want it.

So when I try to run this button Access comes up with the error message

Compile error:
Invalid use of Me keyword.

Please let me know if there's a solution for this or if you need anymore explanation.

Thanks in advance!
Apr 8 '10 #1

✓ answered by vb5prgrmr

But what you can do is pass a reference to the form...

Start a new standard exe project, add a command button to form1 (command1), add the code...
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2. ChangeMyCaption Me, "Form1 Caption Change"
  3. End Sub
  4.  
Now add module and add code...
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Public Sub ChangeMyCaption(F As Form, NewCaption As String)
  4. F.Caption = NewCaption
  5. End Sub
  6.  


Good Luck

4 3808
You can not use me keyword in different module. As me keyword significant the current form.
Apr 8 '10 #2
vb5prgrmr
305 Expert 100+
But what you can do is pass a reference to the form...

Start a new standard exe project, add a command button to form1 (command1), add the code...
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2. ChangeMyCaption Me, "Form1 Caption Change"
  3. End Sub
  4.  
Now add module and add code...
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Public Sub ChangeMyCaption(F As Form, NewCaption As String)
  4. F.Caption = NewCaption
  5. End Sub
  6.  


Good Luck
Apr 8 '10 #3
Thanks a lot for both answers I received!

Thanks specially to vb5prgrmr! You definitely understood my query and I can now use the code in my own little project.

You guys are so good!

From a very satisfied newbie here...
Apr 9 '10 #4
vb5prgrmr
305 Expert 100+
Not a problem, good luck
Apr 9 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Charley Kyd | last post by:
I'm a newbie who needs advice about how to use external files of JavaScript code. I spent an hour this afternoon browsing through JavaScript books at the local book store. In about 15 different...
59
by: seberino | last post by:
I've heard 2 people complain that word 'global' is confusing. Perhaps 'modulescope' or 'module' would be better? Am I the first peope to have thought of this and suggested it? Is this a...
1
by: trapeze.jsg | last post by:
Hi. I am trying to get through to Microsoft MapPoint Services using ZSI for soap handling. I can generate the service classes and also the soap-requests generated by the service classes seem to...
3
by: Mark E. Fenner | last post by:
Hello all, I was migrating some code from sets.ImmutableSet to frozenset and noticed the following: ******code******** #!/usr/bin/env python from sets import ImmutableSet
18
by: Method Man | last post by:
If I don't care about the size of my executable or compile time, is there any reason why I wouldn't want to inline every function in my code to make the program run more efficient?
4
by: NetMasker | last post by:
How can I reference a form (from withing a module for example) and make it visible without using the keyword "Me" ? I tried with the following code but nothing happened: Public myform As Form1...
2
by: DaTurk | last post by:
Hi, I have an interesting issue, well, it's not really an issue, but I'd like to understand the mechanics of what's going on. I have a file, in CLI, which has a class declared, and a static...
10
by: Armando Serrano Lombillo | last post by:
Why does Python give an error when I try to do this: Traceback (most recent call last): File "<pyshell#40>", line 1, in <module> len(object=) TypeError: len() takes no keyword arguments but...
3
by: Sean DiZazzo | last post by:
Why is the following not working? Is there any way to get keyword arguments working with exposed XMLRPC functions? ~~~~~~~~~~~~~~~~ server.py import SocketServer from SimpleXMLRPCServer import...
1
by: prasath03 | last post by:
Hi Gurus, I am doing one website project that project contains one search module. In that search page i have entered the keyword to search. If i want to search the keyword with "any keyword" or...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.