Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2004

    Unanswered: Hidden Tabledefs


    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


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

  2. #2
    Join Date
    Aug 2004

    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


    Set tdfTo = dbsTo.CreateTableDef(cmbJobName)

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

    Would life be easier without M$ Access?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts