Private Sub Save_Click()
?.
?.
Dim strnumber as string
strnumber = Me.Text26.Value
With check ?check is a recordset
.FindFirst ("shipment_no = ' " & strnumber & "'")
If .NoMatch Then
.AddNew
check![shipment_no] = Me.Text26
check![nom to receiver] = Me.Check1
check![nom to terminal] = Me.Check7
.Update
Else
.Edit
check![shipment_no] = Me.Text26
check![nom to receiver] = Me.Check1
check![nom to terminal] = Me.Check7
.Update
End If
End With
End Sub
I have a form which consists of 2 checkboxes for 2 labels (nom to receiver and nom to terminal). From the above code, strnumber is a shipment number which is unique for each shipment. For every new shipment, when I click the Save command button, it will save the values of the 2 checkboxes into a recorsdset (check). However, when I reopen the form to make changes to the checkboxes and click save, it will add duplicate records into the recordset.
From my above code, I would like to edit the record for any previous record when I click the save_button but it didn?t work. Instead it just keep on adding duplicate records.
Anyone knows how to edit previous record and add when the record is new?
thanks