Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create New Table

Status
Not open for further replies.

trevor3208

Technical User
Feb 23, 2006
3
US
I am using VB6 and need to create a new table in an existing Access 2003 database. The current application is using DAO 3.6 to perform all the other function without problems.

I did a search and found a piece of sample code to do what I need, but it uses ADO. Anyway, I implemented it and was happy to see that it worked as advertised.

My problem is that right after creating the table with ADO, there is DAO code that attempts to make changes to one of the fields (setting AllowZeroLength fo false) and it fails, implying that the table itself cannot be found. But it is there, and a shorttime later the field change works.

Any clue, and just how do you accomplish this table creation ( and setting primary key etc) using DAO. Cant see the forest for the trees!!!!

Martyn
 
I assume that you're using a CREATE TABLE ... SQL statement to create the table with ADO and using a Connection.Execute method to run it. You can run the same SQL in DAO with a db.Execute method where "db" is a DAO Database created with statements of the form

Code:
Dim db As DAO.Database
Set db = DAO.DBEngine(0).OpenDatabase("C:\...")

You are having problems because ADO and DAO are not synchronized and you would have to force a flush of ADO to ensure that the database was properly updated.
 
Yes, that was the forest I couldn't see!

Thanks.

I change the code accordingly, it works to add the table, but same error when accessing it afterwards.

So I closed the DAO object then reopened it after the create and it works fine.

Assume there is some form of 'refresh' that needs doing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top