Hi i am trying to write something that would alert an inputter to the fact that a record for a id no already exists, i only want to make a warning as sometimes the same id no may have mulitple events
the field name is hospno and the table "personal details" an id no would be along the lines of v653
I found this code to put into the before update event on the field in an access form but it just give me a runtime error. sorry if it seems simple i've been writting DB's for years but trying to put more advacne error checking in and learning code!
Can nyone suggest what I am doing wrong or anything else i could try??
the field name is hospno and the table "personal details" an id no would be along the lines of v653
I found this code to put into the before update event on the field in an access form but it just give me a runtime error. sorry if it seems simple i've been writting DB's for years but trying to put more advacne error checking in and learning code!
Can nyone suggest what I am doing wrong or anything else i could try??
Code:
Private Sub hospno_BeforeUpdate()
Dim rslt As Integer
If nz(DLookup("[hospital number]", "personal details", "[hospno]=" & Me.hospno),0) <> 0 Then
rslt = Msgbox ("This number has already been entered. Do you wish to continue?", vbYesNo)
If rslt = vbNo Then
Me.RecNo = Null
Me.RecNo.SetFocus
End If
End If
End Sub
Comment