At first my " Call Update_ProdSAP " is working until i added this few lines
Code:
UpdateReqProdSAPSQL = "UPDATE PROD_SAP " & _
"SET PAT_NAME = PAT_LASTNAME & PAT_FIRSTNAME "
DoCmd.RunSQL UpdateReqProdSAPSQL
For some reasons , the update can work but the call method is not executed.
Any ideas where went wrong ?
Thanks in a advance .
Code:
Private Sub cmd_YesProdSAP_Click()
Dim fDialog As Object
Dim SourcePath As String
Dim Success As Boolean
Dim DelReqProdSAPSQL As String
Dim LoadReqProdSAPSQL As String
Dim UpdateReqProdSAPSQL As String
On Error GoTo ErrorHandler
Set fDialog = Application.FileDialog(3)
Dim varFile As Variant
Success = False
With fDialog
.AllowMultiSelect = False
.Title = "Select excel file to import the data :"
.InitialFileName = "c:\"
If .Show = True Then
For Each varFile In .SelectedItems
SourcePath = varFile
Next
Success = True
Else
Success = False
End If
End With
If Success Then
DelReqProdSAPSQL = "Delete * From Prod_SAP"
DoCmd.RunSQL DelReqProdSAPSQL
DoCmd.TransferSpreadsheet acImport, 8, "Prod_SAP", SourcePath, True, ""
Call Update_ProdSAP
UpdateReqProdSAPSQL = "UPDATE PROD_SAP " & _
"SET PAT_NAME = PAT_LASTNAME & PAT_FIRSTNAME "
DoCmd.RunSQL UpdateReqProdSAPSQL
End If
ErrorHandlerExit:
Exit Sub
ErrorHandler:
MsgBox "Please import the correct file!"
Me.Refresh
Resume ErrorHandlerExit
End Sub