|
-
May 29th, 2008, 05:59 AM
#1
Thread Starter
Frenzied Member
How to populate the tables in Access?
I would like to know how to populate the tables in Access? I have the sample code below but it use DAO.. I want to use ADODB connection, so What reference I can use to populate the access tables into my combo box?
Code:
Dim db As Database
Dim wrk As Workspace
Dim tdf As TableDef
For Each tdf In db.TableDefs
If Left(tdf.Name, 4) <> "MSys" And tdf.Name <> "pass" And tdf.Name <> "KERJA" Then _
cboTable.AddItem tdf.Name
Next tdf
-
May 29th, 2008, 06:15 AM
#2
Re: How to populate the tables in Access?
Code:
SELECT Name
FROM MSysObjects
WHERE (Name Not Like "MSys*")
AND (Type In (1,4,6))
ORDER BY Name
(Type 1 is tables in the MDB file, 4 are tables linked through ODBC, and 6
are other linked tables)
Found Solution At:
http://www.microsoft.com/communities...&cr=&sloc=&p=1
-
May 29th, 2008, 06:18 AM
#3
Re: How to populate the tables in Access?
The reference would be the ActiveX Data Objects Library.
I suspect you already have that in your project, correct?
-
May 29th, 2008, 06:23 AM
#4
Thread Starter
Frenzied Member
Re: How to populate the tables in Access?
Yes, I already have it. Microsoft Active X Data Object 2.7 Library.
But when I uncheck this reference Microsoft DAO 3.6 Object Library, This cannot work "Dim db As Database" used it. Is there any reference I can replace DAO so that I can populate the tables into my combo box.. I don't want to use DAO anymore to populate the tables into my combo box.
Code:
Dim db As Database
Dim wrk As Workspace
Dim tdf As TableDef
For Each tdf In db.TableDefs
If Left(tdf.Name, 4) <> "MSys" And tdf.Name <> "pass" And tdf.Name <> "KERJA" Then _
cboTable.AddItem tdf.Name
Next tdf
-
May 29th, 2008, 08:51 AM
#5
Re: How to populate the tables in Access?
Check some good tutorials on ADO with VB.
Then connect to your Access Db with ADO connection and exceute the query provided by me in a previous post to this thread.
You can use the record set object to populate the combo.
-
May 29th, 2008, 09:28 AM
#6
Re: How to populate the tables in Access?
 Originally Posted by matrik02
But when I uncheck this reference Microsoft DAO 3.6 Object Library, This cannot work "Dim db As Database" used it.
Of course it won't work. You removed the reference which declared Database as a valid variable type.
None of that code, as written, will work.
It has to be rewritten using ADO.
-
May 29th, 2008, 02:47 PM
#7
Re: How to populate the tables in Access?
If this is only to work with .mdb files, amrita's advice is the easiest solution - just open a recordset (which you have done before) using that SQL statement.
If it is to work with other database systems too (perhaps SQL Server and Oracle), I would recommend using the connections .OpenSchema method as the source for the recordset. You can see an example of this in the code of my "reserved words checker", link in my signature.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|