ok so I decided to go a different way and I think it's way better (for everyone's sake) because if I'm importing I can select the file myself.... and if I leave here someone can easily take over.
but I can't pass the filename to the import, any ideas?
Code:
Option Compare Database
Private Sub Command0_Click()
Dim strFile As String 'Filename
Dim strFileList() As String 'File Array
Dim intFile As Integer 'File Number
Dim filename As String
Dim path As String
Dim f As Object
Set f = Application.FileDialog(3)
f.AllowMultiSelect = True
f.show
MsgBox "file chosen = " & f.selectedItems.Count
DoCmd.SetWarnings False
filename = f.selectedItems.Count
'DoCmd.TransferText acImportDelim, , "YOURTABLENAME", filename, False
MsgBox ("import" + filename + "?")
DoCmd.TransferSpreadsheet acImport, , "Tabletest", filename, True
DoCmd.SetWarnings True
DoCmd.OpenQuery "matchedtest"
'DoCmd.SetWarnings False
'DoCmd.RunSQL "DELETE * FROM Tabletest"
Dim SQL As String
'checks for duplicates between the two tables
SQL = "SELECT Books.* FROM Books LEFT OUTER JOIN matchedtest ON matchedtest.[asset number] = Books.[asset number] WHERE Books.[asset number] = IS NOT NULL"
If DCount("*", "matchedtest.[asset number]", "Books.[asset number]") < 1 Then
'msg box if it finds it
MsgBox ("nothing to update")
Exit Sub
Else
MsgBox ("updating")
'string creation and insert
SQL = "INSERT INTO Transactions([asset number])VALUES ('" & [Asset Number] & "')"
End If
CurrentDb.Execute SQL
End Sub
it's just saying it doesn't exist when I try to import it