I have an error in a sub form where I have made a change in the Data Type from Integer to Text due to the length constraint of 10 numbers.
Below is the BeforeUpdate code I am using in the sub form. I want the Disp_ICN_Number field (in the Disposition table) to have a unique value for the Parent form field called CR_CCN (Relational field found in the Disposition table and the Cash_Record table).
Example if I have a CR_CCN value (found in the Parent form referencing the Cash_Record table) of 100 and Disp_ICN_Number value (found in the sub form and that will be going into the Disposition table) of 2 there can not be another Disp_ICN_Number with the value of 2 for the CR_CCN.
But other CR_CCN records can have a Disp_ICN_Number with the value of 2.
Below is the code that worked until I changed the Data Type from integer to text.
--------------------------------------------------------------------------
Private Sub ICN_Number_BeforeUpdate(Cancel As Integer)
Dim SID As String
SID = Me.Disp_ICN_Number.Value
'Check Cash_Record table for duplicate CR_CCN
If DCount("*", "Disposition", "Disp_ICN_Number=" & SID & " AND CR_CCN = " & Me.Parent.CR_CCN) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "Warning!! " _
& vbCr & vbCr & "A Disposition with ICN " & SID & " has been found!." _
& vbCr & "Please verify the ICN and try again", _
vbInformation, "Duplicate Information"
End If
End Sub
--------------------------------------------------------------------------
Here is the code I used in the BeforeUpdate in the Parent form for the CR_CCN
--------------------------------------------------------------------------
Private Sub CR_CCN_BeforeUpdate(Cancel As Integer)
Dim SID As String
SID = Me.CR_CCN.Value
'Check Cash_Record table for duplicate CR_CCN
If DCount("CR_CCN", "Cash_Record", "CR_CCN=" & Chr(34) & SID & Chr(34)) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "Warning!! " _
& vbCr & vbCr & "CCN [ " & SID & " ] has already been used!." _
& vbCr & "Please verify the number and try again."
End If
End Sub
--------------------------------------------------------------------------
All suggestions are welcome!
Thank you,
James

Below is the BeforeUpdate code I am using in the sub form. I want the Disp_ICN_Number field (in the Disposition table) to have a unique value for the Parent form field called CR_CCN (Relational field found in the Disposition table and the Cash_Record table).
Example if I have a CR_CCN value (found in the Parent form referencing the Cash_Record table) of 100 and Disp_ICN_Number value (found in the sub form and that will be going into the Disposition table) of 2 there can not be another Disp_ICN_Number with the value of 2 for the CR_CCN.
But other CR_CCN records can have a Disp_ICN_Number with the value of 2.
Below is the code that worked until I changed the Data Type from integer to text.
--------------------------------------------------------------------------
Private Sub ICN_Number_BeforeUpdate(Cancel As Integer)
Dim SID As String
SID = Me.Disp_ICN_Number.Value
'Check Cash_Record table for duplicate CR_CCN
If DCount("*", "Disposition", "Disp_ICN_Number=" & SID & " AND CR_CCN = " & Me.Parent.CR_CCN) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "Warning!! " _
& vbCr & vbCr & "A Disposition with ICN " & SID & " has been found!." _
& vbCr & "Please verify the ICN and try again", _
vbInformation, "Duplicate Information"
End If
End Sub
--------------------------------------------------------------------------
Here is the code I used in the BeforeUpdate in the Parent form for the CR_CCN
--------------------------------------------------------------------------
Private Sub CR_CCN_BeforeUpdate(Cancel As Integer)
Dim SID As String
SID = Me.CR_CCN.Value
'Check Cash_Record table for duplicate CR_CCN
If DCount("CR_CCN", "Cash_Record", "CR_CCN=" & Chr(34) & SID & Chr(34)) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "Warning!! " _
& vbCr & vbCr & "CCN [ " & SID & " ] has already been used!." _
& vbCr & "Please verify the number and try again."
End If
End Sub
--------------------------------------------------------------------------
All suggestions are welcome!
Thank you,
James