In MS Access, I created a form with Form Name "Form" and created a Text Box named "Path".
When I enter a path in form with "c:Desktop.....xlsx". I should be able to import data from Excel to Access.
I tried using the Macro version in Access using the below code, but I encounter an error.
Function Import()
On Error GoTo Import_Err
Dim Str As String
Str = Forms!Form!Path.Caption
DoCmd.TransferSpreadsheet acImport, 10, "EM", Str, True, ""
Import_Exit:
Exit Function
Import_Err:
MsgBox Error$
Resume Import_Exit
End Function
Error: "Object doesn't support this property or method".
As I plan to give the file to others to run, they will have a different path, so we need to prefix it in their system. So instead if we have form path, then users can input the path in form and run it.