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 / Modules / DAO / VBA / January 2006

Tip: Looking for answers? Try searching our database.

What Library do I need to reference?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Conan Kelly - 20 Jan 2006 17:18 GMT
Hello all,

What Libaray do I need to reference in order to use Database and
TableDef data types in VBA as shown in the example below?

Thanks for any help anyone can provide,

Conan Kelly

Sub TableDefX()

   Dim dbsNorthwind As Database
   Dim tdfNew As TableDef
   Dim tdfLoop As TableDef
   Dim prpLoop As Property

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")

   ' Create new TableDef object, append Field objects
   ' to its Fields collection, and append TableDef
   ' object to the TableDefs collection of the
   ' Database object.
   Set tdfNew = dbsNorthwind.CreateTableDef("NewTableDef")
   tdfNew.Fields.Append tdfNew.CreateField("Date", dbDate)
   dbsNorthwind.TableDefs.Append tdfNew

   With dbsNorthwind
       Debug.Print .TableDefs.Count & _
           " TableDefs in " & .Name

       ' Enumerate TableDefs collection.
       For Each tdfLoop In .TableDefs
           Debug.Print "  " & tdfLoop.Name
       Next tdfLoop

       With tdfNew
           Debug.Print "Properties of " & .Name

           ' Enumerate Properties collection of new
           ' TableDef object, only printing properties
           ' with non-empty values.
           For Each prpLoop In .Properties
               Debug.Print "  " & prpLoop.Name & " - " & _
                   IIf(prpLoop = "", "[empty]", prpLoop)
           Next prpLoop

       End With

       ' Delete new TableDef since this is a
       ' demonstration.
       .TableDefs.Delete tdfNew.Name
       .Close
   End With

End Sub
Alex Dybenko - 20 Jan 2006 17:23 GMT
Hi,
it should be Microsoft DAO 3.60

Signature

Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

> Hello all,
>
[quoted text clipped - 51 lines]
>
> End Sub
Allen Browne - 20 Jan 2006 17:27 GMT
These objects are supplied by the DAO library.

If you are using Access 2000 or later, the library is called:
   Microsoft DAO 3.6 Library

In Access 97, it should be:
   Microsoft DAO 3.51 Library.

More info on the refrences for the different versions of Access here:
   Solving Problems with Library References
at:
   http://allenbrowne.com/ser-38.html

If you are just starting out with DAO, here's a summary:
   The DAO Object Model
at:
   http://allenbrowne.com/ser-04.html

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.

> Hello all,
>
[quoted text clipped - 51 lines]
>
> End Sub
Douglas J. Steele - 20 Jan 2006 21:14 GMT
In addition to the (absolutely correct) answers Alex and Allen gave you, be
aware that if you have references to both ADO and DAO, you'll find that
you'll need to "disambiguate" certain declarations, because objects with the
same names exist in the 2 models. For example, to ensure that you get a DAO
property, you'll need to use Dim prpLoop as DAO.Property (to guarantee an
ADO property, you'd use Dim prpLoop As ADODB.Property)

The list of objects with the same names in the 2 models is Connection,
Error, Errors, Field, Fields, Parameter, Parameters, Property, Properties
and Recordset

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

> Hello all,
>
[quoted text clipped - 51 lines]
>
> End Sub
 
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.