I am trying to check if a value that is entered into a combo box currently exists in a table, and if it doesn't then I would like to insert it. This is the code that I have come up with but I can't seem to make it work. Any help would be great.
Private Sub cboreason_AfterUpdate()
If DCount("downtime_reason", "tbldowntime_reason", """" & Me.cboreason & """") = 0 Then
DoCmd.RunSQL "Insert into tbldowntime_reason (downtime_reason) Values (""" & Me.cboreason.Value & """)"
End If
End Sub
Private Sub cboreason_AfterUpdate()
If DCount("downtime_reason", "tbldowntime_reason", """" & Me.cboreason & """") = 0 Then
DoCmd.RunSQL "Insert into tbldowntime_reason (downtime_reason) Values (""" & Me.cboreason.Value & """)"
End If
End Sub