E
ecwhite
Hello, please i need help and I have been reading topics on this in the forum
but i stilll need help resolving my.
Under the click event of a button to insert a new record, i will like to
check if the an id number has already been entered in the database so i
display a message to let the user know b/c duplicate entry with same Id
number is not allowed. ID number is the primary key for each record for a
patient so it can't be autonumber.
Please read my comments in code
Private Sub cmd_insert_newpatient_rec_Click()
On Error GoTo Err_cmd_insert_newpatient_rec_Click
'On Error Resume Next - this fixes it but nothing else run
If DCount("[table1.id_nbr]", "q_duplicate_IDNo_lookup") >= 1 Then
Dim stIDNOFound_InDB As String
'Note : Macro1 is just a a MsgBox displaying that record using a particular
id number has already been entered in DB
stIDNOFound_InDB = "Macro1"
DoCmd.RunMacro stIDNOFound_InDB
Else
' This part below works perfectly without the DCOUNT part so i can insert
new records
Dim stDocName As String
stDocName = "Query1"
DoCmd.OpenQuery stDocName, acNormal, acEdit
stnewrecinserted = "open_frm_to_display_completed_msg"
DoCmd.OpenForm stnewrecinserted
End If
but i stilll need help resolving my.
Under the click event of a button to insert a new record, i will like to
check if the an id number has already been entered in the database so i
display a message to let the user know b/c duplicate entry with same Id
number is not allowed. ID number is the primary key for each record for a
patient so it can't be autonumber.
Please read my comments in code
Private Sub cmd_insert_newpatient_rec_Click()
On Error GoTo Err_cmd_insert_newpatient_rec_Click
'On Error Resume Next - this fixes it but nothing else run
If DCount("[table1.id_nbr]", "q_duplicate_IDNo_lookup") >= 1 Then
Dim stIDNOFound_InDB As String
'Note : Macro1 is just a a MsgBox displaying that record using a particular
id number has already been entered in DB
stIDNOFound_InDB = "Macro1"
DoCmd.RunMacro stIDNOFound_InDB
Else
' This part below works perfectly without the DCOUNT part so i can insert
new records
Dim stDocName As String
stDocName = "Query1"
DoCmd.OpenQuery stDocName, acNormal, acEdit
stnewrecinserted = "open_frm_to_display_completed_msg"
DoCmd.OpenForm stnewrecinserted
End If