Benginner2212
Member
- Local time
- Yesterday, 23:33
- Joined
- Apr 6, 2023
- Messages
- 52
I am working on a database that will be used to keep track of various cable that are used to connect equipment. The cables are broken down in to cable categories and then by cable numbers. And I need to avoid duplicate cable numbers.
I have a query that is based of a table called tblCableInfomation and only uses the fields cableCategory_PK, which is formatted as a number and the field CableNumber which is a string format. I am trying to use a dcount function to count the number of records in the query, but when I run my code I keep getting a mismatched data error and I can't see what I am doing wrong.
This is my code:
TIA
I have a query that is based of a table called tblCableInfomation and only uses the fields cableCategory_PK, which is formatted as a number and the field CableNumber which is a string format. I am trying to use a dcount function to count the number of records in the query, but when I run my code I keep getting a mismatched data error and I can't see what I am doing wrong.
This is my code:
Code:
Private Sub CableNumber_AfterUpdate()
If DCount("CableNumber", "qryCableNumberCheck", "cableCategory_PK=" & Me.cboCableCategory & "" And "CableNumber='" & Me.CableNumber & "'") > 0 Then
Me.CableNumber.Value = Null
MsgBox "The Loop Worked", vbOKOnly, "Cable Number Verification"
Me.cboCableCategory.SetFocus
Else
MsgBox "The Loop Didn't Work", vbOKOnly, "Try Again"
End If
End Sub
TIA