Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2011
    Posts
    3

    Red face Unanswered: Runtime error 3464 with DCount

    Hi everyone.
    I'm at my first db with access and now I'm facing with a problem I'm not able to solve.
    I have an input form (Inserimento nuovi controlli). The data will be added to a table (Anagrafica contribuenti). Before updating the table I need to check that a field (Partita Iva) is not included in that table. To verify this condition I'm using the following code in the form:
    Code:
    Private Sub pi_LostFocus()
    
    If Not IsNull(Me.pi) Then
    If DCount("[Partita Iva]", "Anagrafica contribuenti", "[Partita Iva] ='" & Me.pi & "'") > 0 Then
    MsgBox "Partita Iva già presente"
    ...
    The field in the form (pi) is text, in the table is numeric.
    I receive the Runtime error 3464
    I can't figure why!
    What's the problem?
    Thanks.

  2. #2
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,420
    Provided Answers: 7
    If it a number filed take out the '
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

  3. #3
    Join Date
    Oct 2011
    Posts
    3
    The destination record in the table is numeric, but the field in the form where the code is written is a text field.
    However, I tried without the ' but the problem remains.

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Quote Originally Posted by tigrotto22 View Post
    The destination record in the table is numeric, but the field in the form where the code is written is a text field.
    The only thing that matters is the data type of the column in the table definition. Moreover, there is no such thing as a "text field" in a form. TextBox controls return data of Variant data type in their Value property (otherwise they could not be Null).

    The correct form (provided there is no typo's in the names) should be:
    Code:
    If DCount("[Partita Iva]", "[Anagrafica contribuenti]", "[Partita Iva] = " & Me.Pi.Value) > 0 Then
    Have a nice day!

  5. #5
    Join Date
    Oct 2011
    Posts
    3
    Thank you Sinndho,

    you are right! Now works correctly.
    I was focused on the data type of the textBox in the form. Now I understand my error!
    Thank you again!
    Bye.

  6. #6
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!
    Have a nice day!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •