473,509 Members | 2,912 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 5531
MLH <CR**@NorthState.net> wrote in
news:5q********************************@4ax.com:
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.*******@worldnet.att.net> wrote in
news:11********************@g49g2000cwa.googlegrou ps.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.methodCall()

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.methodCall()

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**@NorthState.net> wrote in
news:ca********************************@4ax.com:
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
2312
by: Brittany | last post by:
can someone explain to me what if else staments do and what while statements do.
121
9908
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...
41
3372
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
6718
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...
17
3543
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...
11
5620
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
2735
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...
4
6672
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 =...
13
2593
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,...
0
7234
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,...
0
7136
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...
0
7412
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...
1
7069
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...
0
7505
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...
0
4730
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...
0
3203
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1570
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 ...
0
441
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.