tazlastic
asked on
i'm getting a "RUNTIME ERROR 3167", plz help!
This DB had been in use for over a year without many problems. Now, for some reason, I'm getting a runtime error 3167.
When a new record is being entered, the user first inserts the customer's phone number. Then when that text box looses focus, a dCount function counts the number of times that phone number is in that field and displays the number in a txtVisit text box. This enables us to track the number of visits we've been to that customer's site. This always worked fine but in the last few days everytime someone is creating a record that has 2 or more visits, we get the error "runtime error 3167,
record is deleted". I cant figure it out so far. Debugging highlights the line:
varVisit = DCount("[NewEuPh]", "tblNEW", "[NewEuPh] = txtEuPh")
which is what counts the visits. Then I have a series of IF statements like this:
If varVisit > 0 Then
If varVisit = 1 Then
txtVisit = "2nd Visit"
Any ideas would be great! thnx!!
TAZ :-)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
omg, you rock, I'm retarded, cant believe I didnt try that. Compact and repair did the trick. Thanks data-man! thnx for our input too flavo!
TAZ :-)
lCount = cLng(DCount("[NewEuPh]", "tblNEW", "[NewEuPh] = " & txtEuPh))
or if NewEuPh is a text field (in the table) then
Dim lCount as long
lCount = clng(DCount("[NewEuPh]", "tblNEW", "[NewEuPh] = '" & txtEuPh & "'"))
Just one conversion too now :-)