Link to home
Start Free TrialLog in
Avatar of tazlastic
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 :-)
Avatar of flavo
flavo
Flag of Australia image

Dim lCount as long
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 :-)

ASKER CERTIFIED SOLUTION
Avatar of Data-Man
Data-Man
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tazlastic
tazlastic

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 :-)