sanders720
Programmer
Below is a segment of my code.
I am opening a table in a recordset. This part of the loop is checking for data. If the data does not exist, it's okay to add. Otherwise, it should not add it. The problem is, it adds it every time.
I believe there is something wrong with the logic here:
If rsNewTable.EOF Then
I've also tried
If rsNewTable.recordcount=0 then
Complete Segment Listing:
Dim sqlNewTable As String
sqlNewTable = "SELECT * FROM tblSubAssyIsolator " & _
"WHERE JobNo = " & Combo6.Value & " And " & _
"InventorFileName = '" & rs1.Fields("InventorFileName") & "' And " & _
"SubAssy = '" & rs1.Fields("SubAssy") & "'"
If addrec = 1 Then
rsNewTable.Open sqlNewTable, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If rsNewTable.EOF Then
rsNewTable.AddNew
rsNewTable.Fields("JobNo") = Combo6.Value
If Not IsNull(rs1.Fields("InventorFileName")) Then rsNewTable.Fields("InventorFileName") = rs1.Fields("InventorFileName")
rsNewTable.Fields("SubAssy") = rs1.Fields("SubAssy")
rsNewTable.Update
End If
rsNewTable.Close
End If
I am opening a table in a recordset. This part of the loop is checking for data. If the data does not exist, it's okay to add. Otherwise, it should not add it. The problem is, it adds it every time.
I believe there is something wrong with the logic here:
If rsNewTable.EOF Then
I've also tried
If rsNewTable.recordcount=0 then
Complete Segment Listing:
Dim sqlNewTable As String
sqlNewTable = "SELECT * FROM tblSubAssyIsolator " & _
"WHERE JobNo = " & Combo6.Value & " And " & _
"InventorFileName = '" & rs1.Fields("InventorFileName") & "' And " & _
"SubAssy = '" & rs1.Fields("SubAssy") & "'"
If addrec = 1 Then
rsNewTable.Open sqlNewTable, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If rsNewTable.EOF Then
rsNewTable.AddNew
rsNewTable.Fields("JobNo") = Combo6.Value
If Not IsNull(rs1.Fields("InventorFileName")) Then rsNewTable.Fields("InventorFileName") = rs1.Fields("InventorFileName")
rsNewTable.Fields("SubAssy") = rs1.Fields("SubAssy")
rsNewTable.Update
End If
rsNewTable.Close
End If