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 > DCOUNT a number data type - error 3464

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-12-12, 10:23
Foskbou Foskbou is offline
Registered User
 
Join Date: Jun 2010
Posts: 109
DCOUNT a number data type - error 3464

Hi - I'm getting a run-time error '3464' Data type mismatch on this code that PTLU is a number field. I use it elsewhere for different text fields without error?

Private Sub PTLU_BeforeUpdate(Cancel As Integer)
If DCount("*", "PROGOULDACCOUNTS11510", "PTLU = '" & Me.PTLU & "'") > 0 Then
MsgBox Me.PTLU & " already used!" & vbCrLf & vbCrLf & _
"Check account number and try again." & vbCrLf & _
Cancel = True
Me.Undo
Me.PTLU.SetFocus


End If
End Sub
Reply With Quote
  #2 (permalink)  
Old 01-12-12, 10:37
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
if its a number field (AKA column), then why are you encapsualting it with quote marks

if its a text / string literal / column then use quite marks
eg:-
'this is required for text or string columns'
"if you need to use a quote mark, escape it first using \'"

if its a a string representation of a date then it must be encapusalted with # and in US or ISO format
eg:-
us #mm/dd/yyyy#
ISO #yyyy/mm/dd#

using the syntax
Code:
if dcount(.....
is asking for trouble as you are doing no checks on the returning value. if the dcoutn returns null you could have issues. far better to assign the value of the dcount to a variant and then do error checking on the resultant value to make certain your code behaves sanely
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 01-12-12, 11:19
Foskbou Foskbou is offline
Registered User
 
Join Date: Jun 2010
Posts: 109
I changed to :
Private Sub PTLU_BeforeUpdate(Cancel As Integer)
If DCount("*", "PROGOULDACCOUNTS11510", PTLU = Me.PTLU) > 0 Then
MsgBox Me.PTLU & " is already used!" & vbCrLf & vbCrLf & _
"Check account number and try again." & vbCrLf & _
Cancel = True
Me.Undo
Me.PTLU.SetFocus


End If
End Sub

and tested it with duplicate entry for that field.
I got a message box that says False with an OK button, then a run-time 2108 you must save the field before you execute the GoToControl action , the GoToControl method, or the SetFocus method on Me.PTLU.SetFocus

What I need it to do is check PTLU(number) if an exact match being entered, msgbox the user that it's already used, clear the entry and put them back in PTLU so they can enter the correct number
Every entry in this form has a number they are picking up from paperwork, and they will never ever be the same

I've done this with text, very confused how to do for number field - any direction you can provide is greatly appreciated!
Reply With Quote
Reply

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