I have a bigger question but lets start with this problam...
I have created a new moudle, with a public sub.
and when I try to excute this sub from a form it gives me an error of:
compile error: sub or function not defined
thats the idea of 'public' so it will be defined on all forms isn't ?
any ideas why it doesn't work ?
12 14971
I have a bigger question but lets start with this problam...
I have created a new moudle, with a public sub.
and when I try to excute this sub from a form it gives me an error of:
compile error: sub or function not defined
thats the idea of 'public' so it will be defined on all forms isn't ?
any ideas why it doesn't work ?
Hi, zivon.
Believe it or not, but function/sub declared as public in code module may be invoked in any module. ;)
The reason why it is not working in your case may be more clear if you provide additional information.
Sorry, but in order for a Public sub/form to be called from any form in a database, it has to be placed in a standard module, not in a code module behind a form! From the object dialog box, Modules - New and enter your code for the sub. When prompted to name the module, name it anything except the same name as the sub/function!
Linq ;0)>
thats what I was thinking, but it doesn't work : \
here is what I'm trying
a moudle called 'email'
Public Sub test()
MsgBox ("this is a test")
End Sub
on the form:
Private Sub test_Click()
test
End Sub
This drove me a nutz for a bit, but I needed the distraction! The problem is
Public Sub test()
MsgBox ("this is a test")
End Sub
on the form:
Private Sub test_Click()
test
End Sub
You were confusing Access by calling both the public sub and the control you were using to call it the same thing! Once I changed one of them the problem was resolved!
Linq ;0)>
I change the name of the public sub to testing... and it still doesn't work...
same problam: "compile error: sub or function not defined"
I've also tried to change the name on the module to TesTing, to see if it also changes it on the form, and it does... : \
I change the name of the public sub to testing... and it still doesn't work...
same problam: "compile error: sub or function not defined"
I've also tried to change the name on the module to TesTing, to see if it also changes it on the form, and it does... : \
Try to call it referencing explicitely to the module.
email.testing
compile error: variable not defined
I think access hates me :)
email.testing
compile error: variable not defined
I think access hates me :)
I've not succeded to reproduce your situation.
I suggest you to reproduce it in blank database made from scratch, zip it and attach to a post.
I agree! As I previously indicated, I couldn't reproduce the error either except when the sub and control being clicked shared names.
Linq ;0)>
I took your advice of trying to open a new db.
and it worked, then I figure out what the problam is, it wasn't a module what I was using... I'm not sure what it is, maybe a class module ?
anyway it had another icon.
thanks for everything ! :)
@FishVal
Worked... Thanks a lot... :) :)
Actually, a Public Sub that exists in a Code Module behind a Form can be called since, under this context, it is actually a Method of the Form. You must first check and see if the Form is Loaded, and if it is, you must preface the Procedure with the Form Name. The following Code is fully operational and will illustrate this concept: - If CurrentProject.AllForms("Form2").IsLoaded Then
-
Call Forms("Form2").PublicSubInForm2
-
End If
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Banaticus Bart |
last post by:
I wrote an abstract base class from which I've derived a few other
classes. I'd like to create a base class array where each element is
an instance of a derived object. I can create a base class...
|
by: john bailo |
last post by:
I am attempting to create a c# program to iterate through the messages in an
Outlook/Exchange
public folder and extract the headers. My apologies to the VB/VBA groups,
but you seem to
have more...
|
by: Sahil Malik [MVP] |
last post by:
Public Private Key Pairs - How do they work?
-----------------------------------------------
I was looking at a presentation recently in which it was suggested that -
User 1 Encrypts a message...
|
by: |
last post by:
All the fields in webforms are automatically declared as protected.
If I change them to public, they are converted back to protected.
Why is this happening ?
Thanks
|
by: Burak |
last post by:
Hello,
I have a web service that has a two user defined public classes. For
sake of brevity, I'll write them as follows
Public Class Service1
Public Class Class1
Public x as integer
End...
|
by: Nick Dreyer |
last post by:
Is it possible to see public class variables of a COM addin in Excel 97 VBA?
I have successfully created the (Visual Basic 2003 .NET) COM
and referenced it in an Excel 97 VBA project. The VBA...
|
by: D Witherspoon |
last post by:
What is happening is that I have a class (ClassA) that inherits a class
(ClassB) which inherits System.Net.Mail.MailMessage
Project 1 references Project 2,
Project 2 references Project 3.
...
|
by: Sky |
last post by:
Hello:
I'm trying to make sense of snk files, when to use, under what conditions to
regenerate new ones,...can someone take a look if these statemes make sense?
And then the final questions at the...
|
by: =?Utf-8?B?SmF5IFBvbmR5?= |
last post by:
I am trying to access a Public property on a Master Page from a Base Page.
On the content pages I have the MasterType Directive set up as follows:
<%@ MasterType virtualpath="~/Master.master" %>...
|
by: fgh.vbn.rty |
last post by:
Hi,
I'm not sure if i'm asking the question correctly but anyway here it
is.
Say I have 3 classes - class A, class B, class R.
1) A and B are the building blocks and R is like a repository...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
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)...
|
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: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |