Solved

Declaration using Public

Posted on 1998-08-02
2
147 Views
Last Modified: 2010-05-03
May i know what are the differences between the
Public db as Database &
Dim db as Database?

When I am using the Public db as Database, the compilation error of UserDefined type not specified is given..

Please give me advice when should i use the Public to declare variable and how?

Waiting for ur reply, thanks

SRQ
0
Comment
Question by:SRQ
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
clifABB earned 100 total points
ID: 1467506
With the error you have received, it looks like you haven't added a reference to the Data Access Object (DAO).
In VB's main screen, select menu option Project/References.  From the dialog box scroll down till you get to the DAO objects.  Unless you have a reason to select a lower version number, select the DAO with the highest object number.

It seems MS is a pain in the behind on this.  Most apps developed with VB will use the DAO and yet the reference to it isn't defaulted.

As far as advice on using Public as opposed to Private.  You should try your hardest to avoid using public variables.  Public variables are harder to debug.

There are times when you do want a Public variable (a database object is a good example) usually this will be a variable which will not change in the life of the app.  Most variables you definitely do not want to be public (a loop counter is a good example).  Many a time I have wanted to kick a programmer who made a loop variable public and then the app ended up going through two loops at the same time in different parts of the app.
0
 

Author Comment

by:SRQ
ID: 1467507
u have answered my question well, thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question