For the benefit of others, here's your code with indents and code tags. Makes for easier reading.
Code:
Private Sub Nummer_BeforeUpdate(Cancel As Integer)
Dim chkBestaan, chkBestaan1, strSQL
chkBestaan = DLookup("nummer", "bonnen_status", "nummer=" & Me.Nummer & " and soort=" & Me.Soort)
If chkBestaan > 0 Then
chkBestaan1 = DLookup("nummer", "bonnen_status", "nummer=" & Me.Nummer & " and soort=" & Me.Soort & " and vastgesteld='N'")
If chkBestaan1 > 0 Then
strSQL = "INSERT INTO Bonnen_status_TMP (nummer, soort, datum_in_omloop, datum_retour, status, eigenaar, nieuw) select nummer, soort, datum_in_omloop, datum_retour, status, eigenaar, 'N' FROM bonnen_status WHERE nummer=" & Me.Nummer & " AND soort = " & Me.Soort & ";"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
strSQL = "UPDATE Bonnen_status SET status='R', vastgesteld='J', datum_retour='" & Forms![invoice_head]!Datum & "' WHERE nummer=" & Me.Nummer & " AND soort = " & Me.Soort & ";"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
Else
MsgBox ("Deze bon heeft al een definitieve status. Strookje opvragen!")
Me.Nummer.Undo
End If
Else
MsgBox ("Onbekend bonnummer. Controleren!")
End If
End Sub
Without looking too closely at your code, note that you don't set cancel = true.
I would also use the db.Execute method with dbFailOnError that will roll back changes if there's an error.
Code:
Dim chkBestaan, chkBestaan1, strSQL
These are all being dimensioned as variants. I would use Dcount rather than Dlookup and dim them as integers and strSql as string.