473,586 Members | 2,566 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What's the default choice if Public/Private is ommited from the Sub statement?

MLH
What's the default declaration if Public/Private is ommited
from the Sub statement in an Access 97 procedure?
Nov 13 '05 #1
8 5539
MLH <CR**@NorthStat e.net> wrote in
news:5q******** *************** *********@4ax.c om:
What's the default declaration if Public/Private is ommited
from the Sub statement in an Access 97 procedure?


Easily tested. Paste this into a module:

Sub TestMe()
MsgBox "It worked!"
End Sub

and then see what happens when you call it from the Debug
window.

Now, paste the same sub into a form's module, open the form and call
it as:

Forms!frmMyForm .TestMe

You'll see that there's consistency of result between the two
contexts.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #2
For the code behind a Form, the default is "Private".
In a Module, the default is "Public".

MLH wrote:
What's the default declaration if Public/Private is ommited
from the Sub statement in an Access 97 procedure?


Nov 13 '05 #3
"Chuck Grimsby" <c.*******@worl dnet.att.net> wrote in
news:11******** ************@g4 9g2000cwa.googl egroups.com:
MLH wrote:
What's the default declaration if Public/Private is ommited
from the Sub statement in an Access 97 procedure?


For the code behind a Form, the default is "Private".
In a Module, the default is "Public".


In what sense is that the case?

If you ran the test that I posted, you'd see that your answer is
misleading, as undeclared subroutines are public by default.

--
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 wrote:
In what sense is that the case?

If you ran the test that I posted, you'd see that your answer is
misleading, as undeclared subroutines are public by default.


Can someone (davis, Chuck, anyone) give an example of when a public
procedure in a FORM is necessary and works?

In the past, I've sometimes written a proc or two that would be nice to
be available to all other forms open at the same time a particular form
is open, with an error trap on the calling form to say ("you must have
such and such a screen open to perform this task") but I've never been
able to have a function/sub declared public on a form module accessible
by other forms. So anything I want accessible by more than one form, I
pop into a standard module.
--
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 #5
rkc
Tim Marshall wrote:
David W. Fenton wrote: In the past, I've sometimes written a proc or two that would be nice to
be available to all other forms open at the same time a particular form
is open, with an error trap on the calling form to say ("you must have
such and such a screen open to perform this task") but I've never been
able to have a function/sub declared public on a form module accessible
by other forms. So anything I want accessible by more than one form, I
pop into a standard module.


Forms.Form1.met hodCall()

or

dim f as access.form
set f = Forms.Form1
f.methodCall
The way I see things, a public method in a form should perform some
kind of operation on that form. If it doesn't it's not really a
member of that object so it belongs in a module.


Nov 13 '05 #6
rkc wrote:
have such and such a screen open to perform this task") but I've never
been able to have a function/sub declared public on a form module
accessible by other forms.
Forms.Form1.met hodCall()

dim f as access.form
set f = Forms.Form1
f.methodCall


Ahhhhhh! I've simply just put the name of the proc down, without
reference to the form. There ya go! 8)
The way I see things, a public method in a form should perform some
kind of operation on that form. If it doesn't it's not really a
member of that object so it belongs in a module.


I'd agree with that.

Thanks!
--
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
MLH
Based on a summarization of what I've read in
all your posts, I think it best that I begin explicitly
declaring them public or private as deemed
needed.

I have not been doing so. It appears to be good
programming practice.
Nov 13 '05 #8
MLH <CR**@NorthStat e.net> wrote in
news:ca******** *************** *********@4ax.c om:
Based on a summarization of what I've read in
all your posts, I think it best that I begin explicitly
declaring them public or private as deemed
needed.

I have not been doing so. It appears to be good
programming practice.


It's always good programming practice to explicitly declare anything
at all.

And you should also make the scope/data types as narrow as possible
to get the job done.

Asking yourself the question "should this be public?" or "should
this be a variant or a string?" requires addressing a whole lot of
issues outside the narrowest scope of the problem you are addressing
with the code you're writing. Getting in the habit of asking
yourself what the narrowest definitions can be will help make your
code better.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #9

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

Similar topics

1
2321
by: Brittany | last post by:
can someone explain to me what if else staments do and what while statements do.
121
9988
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode support IDEs are DreamWeaver 8 and Zend PHP Studio. DreamWeaver provides full support for Unicode. However, DreamWeaver is a web editor rather...
41
3397
by: Mountain Bikn' Guy | last post by:
What is the current preferred way to save user preferences in dotnet? Is the registry the right place to do this? Can anyone recommend a good article (or book) for this topic? Thanks.
3
6738
by: Marty McFly | last post by:
Hello, I have a control class that inherits from System.Web.UI.WebControls.Button. When I drag this control from the "My User Controls" tab in the toolbox onto the form, I want it to reflect the following default properties: Height = 32px, Width = 144px. I declare the Width property in my control as... \\\
17
3556
by: baibaichen | last post by:
i have written some code to verify how to disable slicing copy according C++ Gotchas item 30 the follow is my class hierarchy, and note that B is abstract class!! class B { public: explicit B(INT32 i =0):i_(i){} virtual ~B(){}
11
5633
by: prefersgolfing | last post by:
I'm trying to find on MSDN, or someplace, that speaks to variables being public or private by default. Anyone know where? Thanks.
2
2746
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include <string>
4
6679
by: grizggg | last post by:
I have searched and not found an answer to this question. I ran upon the following statement in a *.cpp file in a member function: static const char * const pacz_HTMLContentTypeHeader = "Content-Type: text/html\r\n"; Why is the second const needed and what does it do? Thanks
13
2597
by: ishakarthika | last post by:
how can i compare the a private variable of a class and a value in the column of a text file. there is a syntax error in my code while comparing. senario is i am getting bus details like busno, source , destination,type of bus, price/head . I should compare the busno which i get through object to the bus no which is present in a .txt file. and...
0
7839
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...
0
8202
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
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...
1
7959
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...
0
8216
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...
0
6614
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...
1
5710
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...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.