-
Error 13 when attaching a table
Not sure why this attach table code doesn't work anymore. . .
and gives an error, its been working for years, just put it in a new 2007 database.
dbtype = "Microsoft Access"
Error is - 13 - Type mismatch
Using 2.8 Library
[vba]
Public Sub AttachTable(ByVal pstrDatabasePath, ByVal tblname, Optional ByVal tblNewname)
On Error GoTo Attach_Err
If IsNull(tblNewname) Then tblNewname = tblname
Debug.Print "tblNewname = " & tblNewname
Debug.Print "Database path = " & pstrDatabasePath
With DoCmd
.DeleteObject acTable, tblNewname
.TransferDatabase acLink, dbType, pstrDatabasePath, acTable, tblname, tblNewname
End With
Exit_Sub:
Exit Sub
Attach_Err:
If Err.Number = 7874 Then
Debug.Print Err.Number & " " & Err.Description & " when deleting table from local database - Macro continues"
Resume Next
ElseIf Err.Number = 3011 Then
Debug.Print Err.Number & " " & Err.Description & " when attaching table from an access database"
MsgBox "Wrong Access database! Please select the correct Access database!", vbCritical, "Financial Planning and Analysis"
Else
Debug.Print Err.Number & " " & Err.Description
MsgBox Err.Number & " " & Err.Description & " " & tblname, vbCritical, "Financial Planning and Analysis"
End If
End Sub
[/vba]
-
I would specify the parameters type, ByVal pstrDatabasePath as String...
This way there's no questions as to what type of parameter is expected.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules