lookforsmt
Registered User.
- Local time
- Today, 06:43
- Joined
- Dec 26, 2011
- Messages
- 672
HI!
I have below code to prompt user to first input location and second prompt to input file name (excel filename "Text" to access table "tbl_Text"
I input the location and file name, but it gives me error
Can anyone advice me what i am doing wrong.
I am inputting location as E:\Access4.0\Reports and
input File name as Text.xlsx
I have below code to prompt user to first input location and second prompt to input file name (excel filename "Text" to access table "tbl_Text"
I input the location and file name, but it gives me error
The action or method requires a File Name argument
Code:
Private Sub Import_File_Click()
On Error GoTo Err_Import_File_Click
Dim strFile_Path As String
Dim strTable As String
'Prompt user for file path
strFile_Path = InputBox("Please enter file path")
'Prompt user for name of table to create for imported data
strTable = InputBox("Please enter name of new table")
'Import file, using inputted file path and table name
DoCmd.TransferSpreadsheet acImport, , strFile_Path & strTable
Exit_Import_File_Click:
Exit Sub
Err_Import_File_Click:
If Err.Number = 3011 Then
MsgBox strFile_Path & " is not a valid path, please try again", vbExclamation, "Invalid File Path"
Else
MsgBox Err.Description
End If
Resume Exit_Import_File_Click
End Sub
Can anyone advice me what i am doing wrong.
I am inputting location as E:\Access4.0\Reports and
input File name as Text.xlsx