Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / March 2007

Tip: Looking for answers? Try searching our database.

public vs private

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nancy - 14 Mar 2007 17:20 GMT
I am not a programmer but I have had to learn to wrote simple code to
calculate an amount due based upon entries in several fields.  It works but
now I'm concerned about the need for the same code to work in all queries and
reports that utilize those fields and the resulting calculation.  Can someone
help me understand -- the public/private code issue.  And, I don't understand
how to make it public if that's what I need to do.  Any help you can offer
will be appreciated.
Signature

nhb -- nc

Allen Browne - 14 Mar 2007 17:25 GMT
Firstly, there are 2 kinds of code modules in Access:
a) those that show up on the Modules tab of the Database window;
b) those that are part of a form/report.

You need the code in (a) if you plan to use it across different
forms/reports/queries.

When the code is in a standard module like that, it is public by default.
You can add Public to the declaration for clarity, but it makes no
difference. If you add Private to the declaration, the procedure will only
be available to other routines in that module.

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

>I am not a programmer but I have had to learn to wrote simple code to
> calculate an amount due based upon entries in several fields.  It works
[quoted text clipped - 7 lines]
> how to make it public if that's what I need to do.  Any help you can offer
> will be appreciated.
onedaywhen - 15 Mar 2007 15:22 GMT
> Firstly, there are 2 kinds of code modules in Access:
> a) those that show up on the Modules tab of the Database window;
> b) those that are part of a form/report

Stefan Hoffmann wrote:
> First of all, there are two types of modules:
> - class modules, which carry the code behind a form or a report
> - standard modul, which is only a collection of code

[OT]:
Firstly and first of all, there are two kinds of posters in Access
newsgroups:
- a) those who think there are 2 types of code modules;
- b) those who think it's not that simple ;-)

Jamie.

--
Stefan Hoffmann - 15 Mar 2007 15:50 GMT
hi Jamie,

> Firstly and first of all, there are two kinds of posters in Access
> newsgroups:
> - a) those who think there are 2 types of code modules;
> - b) those who think it's not that simple ;-)
<g> but it is a good pragmatical approach.

mfG
--> stefan <--
onedaywhen - 16 Mar 2007 09:13 GMT
On Mar 15, 2:50 pm, Stefan Hoffmann <stefan.hoffm...@explido.de>
wrote:
> hi Jamie,
>
[quoted text clipped - 5 lines]
>
> <g> but it is a good pragmatical approach.

<g> also but I could justify a classification of three i.e.

1) Microsoft Access Class Objects
2) Modules
3) Class Modules

Jamie.

--
Stefan Hoffmann - 16 Mar 2007 10:18 GMT
hi Jamie,

onedaywhen schrieb:
> <g> also but I could justify a classification of three i.e.
> 1) Microsoft Access Class Objects
> 2) Modules
> 3) Class Modules
Don't think so. They are all just class modules.

1) Code behind form modules are just two part classes/objects as you
have in .Net.

2) Same thing as 1). As you can declare properties in it, they are
classes. The look like a lazy singelton implentation to me.

3) "Real" classes.

You just have not full access on the class source in 1) and 2).

mfG
--> stefan <--
onedaywhen - 16 Mar 2007 17:32 GMT
On Mar 16, 9:18 am, Stefan Hoffmann <stefan.hoffm...@explido.de>
wrote:
> hi Jamie,
>
[quoted text clipped - 4 lines]
>
> Don't think so. They are all just class modules.

Then why are then on different levels in the VBE project explorer
treeview? It's not my classification <g>!

Jamie.

--
Stefan Hoffmann - 19 Mar 2007 09:59 GMT
hi Jamie,

>>> 1) Microsoft Access Class Objects
>>> 2) Modules
>>> 3) Class Modules
>> Don't think so. They are all just class modules.
> Then why are then on different levels in the VBE project explorer
> treeview? It's not my classification <g>!
To make understanding easier for the beginner. To give a better
presentation of it.

But this is some kind of speculation. Only some of the Access team
members can enlighten us here :)

mfG
--> stefan <--
onedaywhen - 19 Mar 2007 13:29 GMT
On Mar 16, 9:18 am, Stefan Hoffmann <stefan.hoffm...@explido.de>
wrote:
> As you can declare properties in it, they are
> classes.

I can declare properties in Standard Module (.bas) so does that make
it a class also <g>?

Jamie.

--
Stefan Hoffmann - 19 Mar 2007 14:09 GMT
hi Jamie,

>> As you can declare properties in it, they are
>> classes.
> I can declare properties in Standard Module (.bas) so does that make
> it a class also <g>?
ms-help://MS.MSDN.vAug06.en/dv_vbalr/html/3155edaf-8ebd-45c6-9cef-11d5d2dc8d38.htm
--
You can use Property only at module level. This means the declaration
context for a property must be a class, structure, module, or interface,
and cannot be a source file, namespace, procedure, or block.
--

It is possible to have a property with out a class, but this is
comparing apples and oranges, as it concerns only the newer .Net languages.

So, it may be a class or not. I have no facts for either my assertion or
against it.
From my point of view it is one. A standard module looks for me like a
static class in C#/VB.NET.

mfG
--> stefan <--
Stefan Hoffmann - 14 Mar 2007 17:30 GMT
hi Nancy,

> I am not a programmer but I have had to learn to wrote simple code to
> calculate an amount due based upon entries in several fields.  It works but
> now I'm concerned about the need for the same code to work in all queries and
> reports that utilize those fields and the resulting calculation.  Can someone
> help me understand -- the public/private code issue.
First of all, there are two types of modules:

- class modules, which carry the code behind a form or a report
- standard modul, which is only a collection of code

You need to put your function in a standard module and declare it as
public (e.g. Public Function CalcIt() As Currency).

Private code can only be called form the module in which it is declared.
Public functions can be called from everywhere.

mfG
--> stefan <--
Nancy - 14 Mar 2007 18:43 GMT
Thanks to both of you.  I'm assuming that you mean that I can open a module,
put my code there and then it will apply across the database.  i.e., that
will make it "public."  Is that correct?
Signature

nhb -- nc

> hi Nancy,
>
[quoted text clipped - 16 lines]
> mfG
> --> stefan <--
Allen Browne - 15 Mar 2007 02:06 GMT
Yes. In a standard module, each procedure is publicly available, unless you
explicitly mark it as Private.

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

> Thanks to both of you.  I'm assuming that you mean that I can open a
> module,
[quoted text clipped - 24 lines]
>> mfG
>> --> stefan <--
Nancy - 16 Mar 2007 06:47 GMT
Many thanks.
Signature

nhb -- nc

> Yes. In a standard module, each procedure is publicly available, unless you
> explicitly mark it as Private.
[quoted text clipped - 27 lines]
> >> mfG
> >> --> stefan <--
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.