Question : Importing a simple spreadsheet into access

Could you please tell me the error in this code? I keep getting the error message that...
.DoCmd.TransferSpreadsheet acImport, , "order_placement_data", "C:\My Documents\Meta\My Dropbox\Java\Master_Data.xls", True
...must be an updatable query.


Sub ImportSheetToAccess()
Application.ScreenUpdating = False

If Dir("C:\My Documents\...\master.ldb") = "" Then
Dim axs As Object

Set axs = CreateObject("Access.Application")


    With axs
        .OpenCurrentDatabase "C:\My Documents\...\master.mdb", True
        .DoCmd.OpenTable "order_placement_data"
        .DoCmd.TransferSpreadsheet acImport, , "order_placement_data", "C:\My Documents\...\Master_Data.xls", True
        .CloseCurrentDatabase
    End With

Else
    MsgBox ("Database file is locked. "), vbCritical
    Exit Sub
End If

ExitProc:
Set axs = Nothing
Application.ScreenUpdating = True
End Sub

Answer : Importing a simple spreadsheet into access

Sub ImportSheetToAccess()
Application.ScreenUpdating = False

If Dir("C:\My Documents\...\master.ldb") = "" Then
Dim axs As Object

Set axs = CreateObject("Access.Application")


    With axs
        .OpenCurrentDatabase "C:\My Documents\...\master.mdb", True
        .DoCmd.TransferSpreadsheet acImport, , "order_placement_data", "C:\My Documents\...\Master_Data.xls", True
        .CloseCurrentDatabase
    End With

Else
    MsgBox ("Database file is locked. "), vbCritical
    Exit Sub
End If

ExitProc:
Set axs = Nothing
Application.ScreenUpdating = True
End Sub
Random Solutions  
 
programming4us programming4us