I am a VB6 database programmer and have run into a small problem. The company I work for primarily uses Microsoft Access 2000 for the database that is the back end for our software. Well the functionality that I am currently working on creates a table in one database and then links it into the primary database that is used by the program to store and retrieve data from.
Here's the problem. I can create the table fine but when I go to link the table I get a run time error as follows:
Run-time error '3251': Operation is not supported for this type of object.
I have looked all over the internet to find a solution to this problem but can't seem to figure it out or figure out a better way of accomplishing what I am trying to do. I'll go ahead and post my code and hopefully someone has an idea on what to fix.
VB6 Code:::::::
DBengine is a global variable that points to our workspace.
LinkDB is a global variable that points to the main database that has all of the links in it.
dpc.DBPath is a global class that has the path for all databases
things that I have tried that have not worked:
- put all attributes for the tabledef into one createTableDef command
- creating a new table def and then try appending
- create a new workspace
- Ignoring the error
Everything except ignoring the error breaks at the same point, at the command:
dbstemp.TableDe fs.Append (tdf)
And it is always the same error 3251.
Well if anyone has any insight into this I would appreciate it.
Here's the problem. I can create the table fine but when I go to link the table I get a run time error as follows:
Run-time error '3251': Operation is not supported for this type of object.
I have looked all over the internet to find a solution to this problem but can't seem to figure it out or figure out a better way of accomplishing what I am trying to do. I'll go ahead and post my code and hopefully someone has an idea on what to fix.
VB6 Code:::::::
Code:
Private Function createlink() Dim dbstemp As DAO.Database Dim tdf As DAO.TableDef Set dbstemp = DBEngine.OpenDatabase(LinkDB.Name) On Error Resume Next Set tdf = dbstemp.TableDefs(Name) If Err.Number <> 0 Then On Error GoTo 0 'the link does not exist yet so create it Set tdf = dbstemp.CreateTableDef("ZZZZtesting") 'Create tabledef defining the link to the table we want tdf.Connect = ";DATABASE=" & dpc.DBPath & "\cinfoEIRS.mdb" 'name of the table in the source DB tdf.SourceTableName = "ZZZZtesting" 'Add the tabledef to the link database 'On Error Resume Next dbstemp.TableDefs.Append (tdf) dbstemp.TableDefs.Refresh End If On Error GoTo 0 Set dbstemp = Nothing Set tdf = Nothing End Function
LinkDB is a global variable that points to the main database that has all of the links in it.
dpc.DBPath is a global class that has the path for all databases
things that I have tried that have not worked:
- put all attributes for the tabledef into one createTableDef command
- creating a new table def and then try appending
- create a new workspace
- Ignoring the error
Everything except ignoring the error breaks at the same point, at the command:
dbstemp.TableDe fs.Append (tdf)
And it is always the same error 3251.
Well if anyone has any insight into this I would appreciate it.
Comment