Forcing a number to be read as text in form

RachelKenyon

ACCESS newbie
Local time
Yesterday, 23:58
Joined
Feb 10, 2009
Messages
13
I've got 2003 and the Format of the textbox does not include text as an option. The problem is that I am having to enter an ID number (digits only) to match a table that has that number formatted as text. I get a data mismatch error when I try to run a query/VBA. Any suggestions?
 
a textbox IS text unless you do something with it

but if you bind a textbox to a number field, then it will accept numbers only

now when you say your table is formatted as text, do you mean that the field definition is shown as text?

the only practical issue this involves (other than non-numeric items) is dealing with leading zeroes,
(altthough there clearly are cases in which you would get a type mismatch)

------
now you say you are getting a type mismatch - so how are you trying to use a textbox on a form, in a query or vba?
 
I've got an employee ID field that is formatted as text in the table. The ID is 7 numbers. I have a command button on the form that will not run unless the ID and a "password" are matched. Nothing is bound.

If DLookup("password", "tblEntry", "EmployeeID = " & Forms!frmDateSelector.Text5 & "") = Forms!frmDateSelector!Text7 Then
DoCmd.OpenReport "rptTotal", acViewPreview, , , acWindowNormal
Else
MsgBox "Wrong password"
End If

text5 is the ID on the form
text7 is the password.

I get the error - Data mismatch in criteria.
 
Typo

If DLookup("password", "tblEntry", "EmployeeID = '" & Forms!frmDateSelector.Text5 & "'") Then
 

Users who are viewing this thread

Back
Top Bottom