LarryDavidow
Technical User
I have a table that has two fields combined to form a Key field. I want to use the Dcount function to customize a msgbox when the user enters a value that already exists for that record in the subform.
This is what I have so far...
Dim intCt As Integer
intCt = DCount("[ModCode]", "CastingDetail", "[ModCode] = '" & Me.Modcode & "'"
intCt = DCount("[CastingDetailCode]", "CastingDetail", "[CastingDetailCode] = " & Me.CastingDetailCode & "" + intCt
If intCt <> 0 Then
MsgBox "You have already selected " & Me.Combo10.Column(1) & " for this casting"
Me.Combo10 = ""
Exit Sub
End If
I think I'm going about this the wrong way. The Dcount function will work on the records in the subform, however, I need to make the statement specific to the records that are currently open in the subform and not the entire table. Make any sense??? I hope so. Please help!!!
This is what I have so far...
Dim intCt As Integer
intCt = DCount("[ModCode]", "CastingDetail", "[ModCode] = '" & Me.Modcode & "'"
intCt = DCount("[CastingDetailCode]", "CastingDetail", "[CastingDetailCode] = " & Me.CastingDetailCode & "" + intCt
If intCt <> 0 Then
MsgBox "You have already selected " & Me.Combo10.Column(1) & " for this casting"
Me.Combo10 = ""
Exit Sub
End If
I think I'm going about this the wrong way. The Dcount function will work on the records in the subform, however, I need to make the statement specific to the records that are currently open in the subform and not the entire table. Make any sense??? I hope so. Please help!!!