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 :-)
tazlasticAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

0
Data-ManCOOCommented:
did you copy this line of code?

varVisit = DCount("[NewEuPh]", "tblNEW", "[NewEuPh] = txtEuPh")

shouldn't this be

varVisit = DCount("[NewEuPh]", "tblNEW", "[NewEuPh] = " & txtEuPh)

you may want to compact and repair....back up the database first.

Mike

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tazlasticAuthor Commented:

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 :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.