I have a save button on my form. I want it to update the record if the SkidID is the same. If it's not the same I want it to insert the new record. The problem I'm having is that the SkidID is the same everytime so it never inserts..Can anyone help me?
Code:
Private Sub btnSave_Click()
Dim stDocName As String
'Updating the record based off of txtSkidID
If SkidID = txtSkidID.Value Then
fnDoSQL "UPDATE tbl_Inventory SET Status = '" & Trim(cmboStatus) & " ', Location = '" & Trim(cmboLocation) & "'" & _
"WHERE SkidID = " & Trim(txtSkidID) & " "
End If
If txtSkidID.Value <> SkidID Then
'Insert Function
fnDoSQL "INSERT INTO tbl_Inventory (SkidID, Location, Status) VALUES " _
& "('" & Trim(txtSkidID.Value) & "', '" & Trim(cmboLocation.Value) & "', '" & Trim(cmboStatus.Value) & "')"
End If
'Checking to make sure all fields have information in them before you save
If (IsNull(txtSkidID.Value) = True Or txtSkidID.Value = "" Or IsNull(cmboLocation.Value) = True Or cmboLocation.Value = "" _
Or IsNull(cmboStatus.Value) = True Or cmboStatus.Value = "") Then
MsgBox ("All Fields Must Be Complete!")
End If
End Sub