 |
| 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
|
|
|
|

June 12th, 2007, 07:24 PM
|
|
Registered User
|
|
Join Date: May 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
DAO TableDef eqivalent in ADO
Does anyone know what will replicate this piece of DAO code in ADO? I think I'm looking for the ADO equivalent of TableDef basically....
Dim db As Database
Dim tdf As DAO.TableDef
Set db = CurrentDb
Set tdf = db.TableDefs("TableName")
tdf.Fields(0).Name = "NewFieldName"
|
|

June 13th, 2007, 08:53 AM
|
|
Registered User
|
|
Join Date: Jun 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Try something along these lines:
Dim cat as ADOX.Catalog
Dim tbl as ADOX.Table
Set cat = New ADOX.Catalog
cat.ActiveConnection = CurrentProject.Connection
On Error Resume Next
Set tbl = New ADOX.Table
tbl.Name = "TableName"
tbl.Columns.Append "NewFieldName", <fieldtype>, <fieldlength>
tbl.Columns.Append "NewFieldName2", <fieldtype>, <fieldlength>
< ... etc >
cat.Tables.Append tbl
cat.Tables.Refresh
cat.ActiveConnection = Nothing
Set tbl = Nothing
Set cat = Nothing
------------------------------------------------------------------------------
That's what I got from my WROX book - however I'm having some weird problems with the cat.Tables.Append line. Unfortunately for me, all of the examples I've seen online (I just spent about an hour Googling for this stuff) all have the same syntax as I showed above.
Good luck!
|
|

May 12th, 2010, 01:56 AM
|
|
Registered User
|
|
Join Date: May 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
converting VB6 Appp from DAO to ADO
Please, if anybody can help with the following:
Need to be basically replace TableDef property... I have a table, where I need to read Columns names. Anybody? not DAO but ADO...
|
|

May 12th, 2010, 08:50 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
Always start a new thread if you don't own it are is not related in any way.
Did you try google?? because looping through the fields collection of the recorset is the way to do it (and extracting the name property of it).
__________________
HTH
Gonzalo
================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the proof.
================================================== =========
|
|

May 12th, 2010, 10:12 AM
|
|
Registered User
|
|
Join Date: May 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
TableDef equivalent in ADO
Quote:
Originally Posted by jaz061459
Please, if anybody can help with the following:
Need to basically replace TableDef property... I have a table, where I need to read Columns names. Anybody? not DAO but ADO...
|
Googling did not help.... I need to be able to read columns/fields from existing table, not just to read .adoSchema, but Names of colulmns
|
|

May 12th, 2010, 10:35 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
And looping through the output recordset is not good because???
__________________
HTH
Gonzalo
================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the proof.
================================================== =========
|
|

May 12th, 2010, 10:57 AM
|
|
Registered User
|
|
Join Date: May 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
this basically without details is a code from DAO
Dim db As Database
Dim tdf As DAO.TableDef
Set db = CurrentDb
Set tdf = db.TableDefs("TableName")
tdf.Fields(0).Name = "NewFieldName"
URGENTLY NEED an equivalent for the same using ADO though
|
|

May 12th, 2010, 11:19 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
Ado has a catalog, and a catalog has tables.
You can loop that collection to get your info.
__________________
HTH
Gonzalo
================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the proof.
================================================== =========
|
|

May 12th, 2010, 11:36 AM
|
|
Registered User
|
|
Join Date: May 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
tried, somehow did not work.... sample of code, pls?
|
|

May 12th, 2010, 11:44 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
Help us help you..
Maybe showing your code we can see what is wrong?
That's a way to do it. Also I think that MSDN has some sample codes to do that.
__________________
HTH
Gonzalo
================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the proof.
================================================== =========
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| ADO or DAO |
knowledge76 |
Access VBA |
3 |
October 12th, 2015 04:26 PM |
| DAO vs. ADO |
SerranoG |
Access VBA |
11 |
December 5th, 2006 01:19 PM |
| Dao to Ado |
vrtviral |
Access VBA |
5 |
February 19th, 2005 11:13 AM |
| ADO vs DAO |
perrymans |
BOOK: Expert One-on-One Access Application Development |
0 |
October 24th, 2004 11:36 PM |
| DAO / ADO? |
merguvan |
Access VBA |
8 |
January 18th, 2004 07:39 AM |
|
 |