i'm getting a "RUNTIME ERROR 3167", plz help!

Posted on 2004-11-12
Last Modified: 2011-04-14

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 :-)
Question by:tazlastic
    LVL 34

    Expert Comment

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

    LVL 18

    Accepted Solution

    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.



    Author Comment


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

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
    Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
    Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
    In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now