i have a db that is linked to an excel spreadsheet, but when i add a recordset that links to the spreadsheet it gives me an error "type mismatch"
CODE:
Dim dbs As Database
Dim tdf As TableDef
Dim rs1 As ADODB.Recordset
' Open the Microsoft Access database.
Set dbs = CurrentDb
' Create a TableDef object.
Set tdf = dbs.CreateTableDef("Freight Rates")
' Set the connection string to specify the source database type and the
' path to the workbook that contains the data you want to link.
tdf.Connect = "Excel 5.0;DATABASE=G:\Honda DB Analyser\FreightRates.xls"
' Set the SourceTableName property to the worksheet you want to access.
tdf.SourceTableName = "Sheet1$"
' Append the TableDef object to the TableDefs collection to create a link.
dbs.TableDefs.Append tdf
' Create a Recordset object from the linked Microsoft Excel worksheet.
Set rs1 = dbs.OpenRecordset("Freight Rates")
Also i would like to know how to remove the link.
Thanks
Reta
CODE:
Dim dbs As Database
Dim tdf As TableDef
Dim rs1 As ADODB.Recordset
' Open the Microsoft Access database.
Set dbs = CurrentDb
' Create a TableDef object.
Set tdf = dbs.CreateTableDef("Freight Rates")
' Set the connection string to specify the source database type and the
' path to the workbook that contains the data you want to link.
tdf.Connect = "Excel 5.0;DATABASE=G:\Honda DB Analyser\FreightRates.xls"
' Set the SourceTableName property to the worksheet you want to access.
tdf.SourceTableName = "Sheet1$"
' Append the TableDef object to the TableDefs collection to create a link.
dbs.TableDefs.Append tdf
' Create a Recordset object from the linked Microsoft Excel worksheet.
Set rs1 = dbs.OpenRecordset("Freight Rates")
Also i would like to know how to remove the link.
Thanks
Reta