Import data that are approved in excel into Access (1 Viewer)

luzz

Registered User.
Local time
Today, 15:10
Joined
Aug 23, 2017
Messages
346
Hi guys, how to import excel data that are only approved into access?

Below is my code for importing data:

Private Sub cmdImport_Click()
Dim filepath As String
filepath = "C:\Users\users\Desktop\FabricPO.xlsx"
If FileExist(filepath) Then
DoCmd.TransferSpreadsheet acImport, , "TempFromExcel", filepath, True
If IsNull(DLookup("[Date]", "NewFabricPO")) Then
MsgBox "No new data to add"
Else
DoCmd.OpenQuery "qryappend", acViewNormal
End If
Else
MsgBox "File not found. Please check filename or file location."
End If
Dim SQLDelete As String
SQLDelete = "delete * from TempFromExcel"
DoCmd.RunSQL SQLDelete
End Sub

Function FileExist(sTestFile As String) As Boolean

'this function does not use DIR since it is possible that uou might have
'been in the middle of running DIR against another directory in
'an attempt to match one directory against another
'it does not handle wildcard characters

Dim lSize As Long
On Error Resume Next
'Preset length to -1 because files can be zero bytes in length
lSize = -1
'get the length of the file
lSize = FileLen(sTestFile)
If lSize > -1 Then
FileExist = True
Else
FileExist = False
End If

End Function
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 15:10
Joined
Aug 30, 2003
Messages
36,134
Looks like you could put the appropriate criteria in your append query.
 

Users who are viewing this thread

Top Bottom