Im trying to update a table from three different excel tables, so what i have done is a union query to get the information i need from the three tables into one query table, Bulk Import. What I'm trying to do with the information in Bulk Import is to update/add to another table Tools v3. I want to add the record from Bulk Import to Tools v3 if it doesnt exist and update it if it does exist. So this is what i have so far:
Dim dbs As Database
Dim rst As DAO.Recordset
Dim Criteria As Form
Dim SQL As String
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Bulk Import")
'SQL = "SELECT [Bulk Import].[Tool Serial], [Bulk Import].[Size] FROM [Bulk Import]"
rst.MoveFirst
While Not rst.BOF
With rst
If DCount([Serial], [Tools v3], "[Tools v3].[Serial] = " & [Bulk Import].[Tool Serial]) = 0 Then
DoCmd.OpenQuery "add tool", acNormal, acAdd
Else
'DoCmd.OpenQuery "tool update", acNormal, acEdit
End If
.MoveNext
End With
Wend
I have done some research on what im doing and it seems that i almost have it but it just doesnt work still. I get an error that says "the field "|" doesnt exist." I'm somewhat new to vba coding so if someone can help me out that would be very much appreciated.
Dim dbs As Database
Dim rst As DAO.Recordset
Dim Criteria As Form
Dim SQL As String
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Bulk Import")
'SQL = "SELECT [Bulk Import].[Tool Serial], [Bulk Import].[Size] FROM [Bulk Import]"
rst.MoveFirst
While Not rst.BOF
With rst
If DCount([Serial], [Tools v3], "[Tools v3].[Serial] = " & [Bulk Import].[Tool Serial]) = 0 Then
DoCmd.OpenQuery "add tool", acNormal, acAdd
Else
'DoCmd.OpenQuery "tool update", acNormal, acEdit
End If
.MoveNext
End With
Wend
I have done some research on what im doing and it seems that i almost have it but it just doesnt work still. I get an error that says "the field "|" doesnt exist." I'm somewhat new to vba coding so if someone can help me out that would be very much appreciated.