If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > Runtime error 3464 with DCount

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-14-11, 18:33
tigrotto22 tigrotto22 is offline
Registered User
 
Join Date: Oct 2011
Posts: 3
Red face 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.
Reply With Quote
  #2 (permalink)  
Old 10-15-11, 01:43
myle myle is offline
(Making Your Life Easy)
 
Join Date: Feb 2004
Location: New Zealand
Posts: 1,143
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
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
Reply With Quote
  #3 (permalink)  
Old 10-15-11, 06:12
tigrotto22 tigrotto22 is offline
Registered User
 
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.
Reply With Quote
  #4 (permalink)  
Old 10-15-11, 06:54
Sinndho Sinndho is offline
Registered User
 
Join Date: Mar 2009
Posts: 3,446
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!
Reply With Quote
  #5 (permalink)  
Old 10-15-11, 12:13
tigrotto22 tigrotto22 is offline
Registered User
 
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.
Reply With Quote
  #6 (permalink)  
Old 10-15-11, 12:33
Sinndho Sinndho is offline
Registered User
 
Join Date: Mar 2009
Posts: 3,446
You're welcome!
__________________
Have a nice day!
Reply With Quote
Reply

Tags
3464, error, runtime

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On