Private Sub cmdGetSmartCardData_Click()
Dim Cancel As Variant
Beep
If MsgBox("Please make sure you insert the Smart Card to the reader." & vbCrLf & "Are you sure you want to proceed?", vbYesNo, "Confirm Excution") = vbNo Then
Cancel = True
Exit Sub
Else
Me.lblWait.Visible = True
On Error Resume Next
Dim strFile As String 'Filename
Dim strFileList() As String 'File Array
Dim intFile As Integer 'File Number
Dim strPath As String ' Path to file folder
Dim User As String
User = Environ("UserName")
strPath = "C:\Users\" & [User] & "\AppData\Local\Temp\"
' strPath = "C:\Users\redha\AppData\Local\Temp\"
strFile = Dir(strPath & "eRevealerGcc*.XML")
While strFile <> ""
'add files to the list
intFile = intFile + 1
ReDim Preserve strFileList(1 To intFile)
strFileList(intFile) = strFile
strFile = Dir()
Wend
'see if any files were found
If intFile = 0 Then
MsgBox "No files found"
Exit Sub
End If
'cycle through the list of files
For intFile = 1 To UBound(strFileList)
Application.ImportXML strPath & strFileList(intFile), 2
Next intFile
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim SQL As String
Dim SQLD1 As String
Dim SQLD2 As String
Dim SQLD3 As String
SQL = "UPDATE Customers, SmartcardData SET Customers.CustomerName = [SmartcardData].[EnglishFullName], " & _
"Customers.[Job Title] = [SmartcardData].[OccupationEnglish], Customers.Address = [SmartcardData].[AddressEnglish], " & _
"Customers.BirthDate = [SmartcardData].[BirthDate], Customers.CardCountry = [SmartcardData].[CardCountry], " & _
"Customers.CardexpiryDate = [SmartcardData].[CardexpiryDate], Customers.CardIssueDate = [SmartcardData].[CardIssueDate], " & _
"Customers.EmploymentId = [SmartcardData].[EmploymentId], Customers.EmploymentNameEnglish = [SmartcardData].[EmploymentNameEnglish], " & _
"Customers.Gender = [SmartcardData].[Gender], Customers.IdNumber = [SmartcardData].[IdNumber], " & _
"Customers.PassportExpiryDate = [SmartcardData].[PassportExpiryDate], Customers.PassportIssueDate = [SmartcardData].[PassportIssueDate], " & _
"Customers.PassportNumber = [SmartcardData].[PassportNumber], Customers.SponserId = [SmartcardData].[SponserId], " & _
"Customers.SponserNameEnglish = [SmartcardData].[SponserNameEnglish]" & _
"WHERE (((Customers.ID)=[Forms]![Customer Details]![ID]));"
SQLD1 = "Delete From SmartcardData"
SQLD2 = "Delete From MiscellaneousBinaryData"
SQLD3 = "Delete From MiscellaneousTextData"
DoCmd.SetWarnings False
DoCmd.RunSQL SQL
DoCmd.RunSQL SQLD1
DoCmd.RunSQL SQLD2
DoCmd.RunSQL SQLD3
DoCmd.SetWarnings True
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Me.lblWait.Visible = False
Refresh
MsgBox "Smart Card data imported successfully", vbOKOnly, "Successful Operation"
End If
End Sub