I have 1 text0=to show path file to be import
1 cmdBrowse = Browse file exel to import
1 cmdImportPlan =for import to table when click
but when i select file it's show error in " DoCmd.TransferSpreadsheet acImport, 8, "tblPlan", Fname, True, "A1:G100"
anyone help me?
this is my coding
Public Function Filename(ByVal strPath As String, sPath) As String
sPath = Left(strPath, InStrRev(strPath, "\"))
Filename = Mid(strPath, InStrRev(strPath, "\") + 1)
End Function
Private Sub Form_Load()
Text0.Value = ""
End Sub
Private Sub CmdBrowse_Click()
Dim f As Object
Set f = Application.FileDialog(3)
f.AllowMultiSelect = True
If f.Show Then
For i = 1 To f.SelectedItems.Count
sFile = Filename(f.SelectedItems(i), sPath)
Text0.Value = sPath & "" & sFile
Next
End If
End Sub
Private Sub CmdImportPlan_Click()
Dim Fname As String
Fname = Text0.Value
Dim LResponse As Integer
If Me.Text0.Value = "" Then
LResponse = MsgBox("Please select file to import!!!", vbOKOnly, "Select File")
ElseIf Me.Text0.Value <> "" Then
LResponse = MsgBox("Do you want to import this file to the system?", vbYesNo, "Confirmation")
If LResponse = vbYes Then
DoCmd.TransferSpreadsheet acImport, 8, "tblPlan", Fname, True, "A1:G100"
LResponse = MsgBox("Import completed", vbOKOnly, "Confirmation")
Me.Text0.Value = ""
Else: LResponse = MsgBox("Cancel import", vbOKOnly, "Confirmation")
End If
End If
End Sub
1 cmdBrowse = Browse file exel to import
1 cmdImportPlan =for import to table when click
but when i select file it's show error in " DoCmd.TransferSpreadsheet acImport, 8, "tblPlan", Fname, True, "A1:G100"
anyone help me?
this is my coding
Public Function Filename(ByVal strPath As String, sPath) As String
sPath = Left(strPath, InStrRev(strPath, "\"))
Filename = Mid(strPath, InStrRev(strPath, "\") + 1)
End Function
Private Sub Form_Load()
Text0.Value = ""
End Sub
Private Sub CmdBrowse_Click()
Dim f As Object
Set f = Application.FileDialog(3)
f.AllowMultiSelect = True
If f.Show Then
For i = 1 To f.SelectedItems.Count
sFile = Filename(f.SelectedItems(i), sPath)
Text0.Value = sPath & "" & sFile
Next
End If
End Sub
Private Sub CmdImportPlan_Click()
Dim Fname As String
Fname = Text0.Value
Dim LResponse As Integer
If Me.Text0.Value = "" Then
LResponse = MsgBox("Please select file to import!!!", vbOKOnly, "Select File")
ElseIf Me.Text0.Value <> "" Then
LResponse = MsgBox("Do you want to import this file to the system?", vbYesNo, "Confirmation")
If LResponse = vbYes Then
DoCmd.TransferSpreadsheet acImport, 8, "tblPlan", Fname, True, "A1:G100"
LResponse = MsgBox("Import completed", vbOKOnly, "Confirmation")
Me.Text0.Value = ""
Else: LResponse = MsgBox("Cancel import", vbOKOnly, "Confirmation")
End If
End If
End Sub