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:
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?
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.
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:
If DCount("[Partita Iva]", "[Anagrafica contribuenti]", "[Partita Iva] = " & Me.Pi.Value) > 0 Then