If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Hidden Tabledefs

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-18-04, 09:46
furries furries is offline
Registered User
 
Join Date: Aug 2004
Posts: 2
Hidden Tabledefs

Hi

I want to create some tabledefs in Jet using VB6. It works, but I can't see the table in Access - Access knows they're there because it won't allow me to create a table with the smae name

Any ideas? Code follows

Thanks


Set tdfFrom = dbsFrom.CreateTableDef(cmbJobName, dbOpenTable)
Set tdfTo = dbsTo.CreateTableDef(cmbJobName, dbOpenTable)

Set rstFrom = dbsFrom.OpenRecordset(cmbJobName, dbOpenTable)
Set rstTo = dbsTo.OpenRecordset(cmbJobName, dbOpenTable)
If Err.Number = 3011 Then
'Create Field Definitions
rstFrom.MoveFirst
For Each fldTemp In rstFrom.Fields
tdfTo.Fields.Append tdfTo.CreateField(fldTemp.Name, fldTemp.Type)
Next fldTemp
On Error GoTo 0

For Each idxTemp In tdfFrom.Indexes
Set idxNew = Nothing
For Each fldTemp In idxTemp
idxNew.Fields.Append idxNew.CreateField(fldTemp.Name, fldTemp.Type)
Next fldTemp
tdfTo.Indexes.Append idxNew
Next idxTemp

dbsTo.TableDefs.Append tdfTo
Set rstTo = dbsTo.OpenRecordset(cmbJobName, dbOpenTable)
Else
Reply With Quote
  #2 (permalink)  
Old 08-25-04, 10:39
furries furries is offline
Registered User
 
Join Date: Aug 2004
Posts: 2
Thumbs up

Thanks for your help guys but I've solved the problem (and another that had bothered me for weeks but I put up with it)

The problem was the way that I opened the tabledef in VB (I used the OpenRecordset syntax so ...)


Set tdfTo = dbsTo.CreateTableDef(cmbJobName, dbOpenTable)

is equivalent to

Set tdfTo = dbsTo.CreateTableDef(cmbJobName, 1)

and you get the symptoms described above.



Set tdfTo = dbsTo.CreateTableDef(cmbJobName, dbOpenDynaset)

is equivalent to

Set tdfTo = dbsTo.CreateTableDef(cmbJobName, 2)

and the table is visible but is a system table



Finally

Set tdfTo = dbsTo.CreateTableDef(cmbJobName)

Creates the table and can be manipulated perfectly in Access. Problem solved!

Would life be easier without M$ Access?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On