Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 3rd, 2005, 03:48 PM
Authorized User
 
Join Date: Oct 2005
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default 2 databases

Does anyone have any idea of how to connect to another access database and get table names and field names? If anyone has sample coding that would help to....thnx in advance

 
Old November 3rd, 2005, 04:55 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 126
Thanks: 5
Thanked 0 Times in 0 Posts
Default

If you link the table from the other database, it will recognize it as it's own in any code, forms, reports, or queries. On the table tab of the database window, click on new, then link table. An open dialog box will come up for you to select the other database, then it will let you choose which table.

Hope I understood what you are trying to do and was a help.


Regards,
Laura

The only thing standing between you and your goal is doubt. Quit doubting yourself and you'll be able to accomplish anything!
 
Old November 3rd, 2005, 10:15 PM
Authorized User
 
Join Date: Oct 2005
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I thank you for your reply but unfortunately link won't help in this case. Let me explain alittle more deeper. I plan on merging two databases and I want to compare table names and fields before hand. So I plan on pulling that information into some form for visual comparison.

 
Old November 4th, 2005, 04:39 PM
Authorized User
 
Join Date: Sep 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, Here's how to do it.

Sub subGetFieldNames(vtxDbName As String, vtxTableName as string)

'Print out field names to the Debug Window

Dim vdb as DAO.Database
Dim vtd as DAO.TableDef
Dim vfd as DAO.Field

   Set vdb = OpenDatabase(vtxDbName)
   set vtd = vdb.TableDefs(vtxTableName)

   For Each vfd In vtd.Fields
       debug.Print vfd.Name 'Note Intellisense tells you properties
       debug.Print vfd.Size

   'If Property does not exist from vfd.Property("PropertyName")
   'You will get an Error
   Next

   vdb.Close

End Sub

Function fuTestFieldNames()

    Call subGetFieldNames("C:\dbs\LibraryBooks.mdb", "tblBook")


End Function
---------------

You will need another loop for the Table Defs. Along the Same lines as for For Each statement.

Watch out for properites you are looking for which are not defined.
You will definitely learn more about what MS Access does to create new properties.

Sal


Database Agreements





Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't get the databases to work Fredrik860 BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 3 November 23rd, 2007 04:40 PM
c++ or c# 2005 for Databases Zergon Visual C++ 2005 0 November 17th, 2006 07:02 AM
databases zmark Access VBA 4 September 14th, 2004 12:51 AM
How many databases can I use? FlashMan Classic ASP Databases 5 July 5th, 2004 03:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.