From: John S. Ford, MD on
I have table tblPatients with the following fields:
PatientIDNum (Autonumber)
PatientNameLast (Text)
PatientNameFirst (Text)
PatientMRNum (Text)

Field PatientMRNum is a 7 character medical record number each character of
which is incidently a numeric character.

I have a form with TextBox txtIDNum in which users the patient's MRNum
number. A command button on the form has the following code:

MsgBox "Is patient " & DLookup("PatientNameLast", "tblPatients",
"PatientMRNum=" & txtPatientMRNum) & " the patient whose chart you're
reviewing?"

Unfortunately, DLookup apparently thinks the contents of txtPatientMRNum are
integers because this code generates a data mismatch error. The code WILL
work perfectly if I change the datatype of PatientMRNum in tblPatients to
Number (but I don't want to do this).

Is there a way to get the txtMRNum to interpret the entry as a simple text
instead of a numeric?

Thanks in advance!

John


From: Jeff Boyce on
Actually, since you're not telling DLookup that PatientMRNum is text, Access
thinks you mean it's a number, and then it chokes on it! That's why you're
getting the type mismatch.

If you want Access to treat what's in [txtPatientMRNum] as text, you'll need
to add quotes around it.


Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

"John S. Ford, MD" <johnsfordNOSPAMmd(a)hotmail.com> wrote in message
news:un8jA296KHA.4804(a)TK2MSFTNGP02.phx.gbl...
>I have table tblPatients with the following fields:
> PatientIDNum (Autonumber)
> PatientNameLast (Text)
> PatientNameFirst (Text)
> PatientMRNum (Text)
>
> Field PatientMRNum is a 7 character medical record number each character
> of which is incidently a numeric character.
>
> I have a form with TextBox txtIDNum in which users the patient's MRNum
> number. A command button on the form has the following code:
>
> MsgBox "Is patient " & DLookup("PatientNameLast", "tblPatients",
> "PatientMRNum=" & txtPatientMRNum) & " the patient whose chart you're
> reviewing?"
>
> Unfortunately, DLookup apparently thinks the contents of txtPatientMRNum
> are integers because this code generates a data mismatch error. The code
> WILL work perfectly if I change the datatype of PatientMRNum in
> tblPatients to Number (but I don't want to do this).
>
> Is there a way to get the txtMRNum to interpret the entry as a simple text
> instead of a numeric?
>
> Thanks in advance!
>
> John
>


From: .Len B on
Use this instead
MsgBox "Is patient " & DLookup("PatientNameLast", "tblPatients",
"PatientMRNum='" & txtPatientMRNum & "'") & " the patient whose
chart you are reviewing?"

--
Len
______________________________________________________
remove nothing for valid email address.
"John S. Ford, MD" <johnsfordNOSPAMmd(a)hotmail.com> wrote in message
news:un8jA296KHA.4804(a)TK2MSFTNGP02.phx.gbl...
|I have table tblPatients with the following fields:
| PatientIDNum (Autonumber)
| PatientNameLast (Text)
| PatientNameFirst (Text)
| PatientMRNum (Text)
|
| Field PatientMRNum is a 7 character medical record number each
character of
| which is incidently a numeric character.
|
| I have a form with TextBox txtIDNum in which users the patient's MRNum
| number. A command button on the form has the following code:
|
| MsgBox "Is patient " & DLookup("PatientNameLast", "tblPatients",
| "PatientMRNum=" & txtPatientMRNum) & " the patient whose chart you're
| reviewing?"
|
| Unfortunately, DLookup apparently thinks the contents of
txtPatientMRNum are
| integers because this code generates a data mismatch error. The code
WILL
| work perfectly if I change the datatype of PatientMRNum in tblPatients
to
| Number (but I don't want to do this).
|
| Is there a way to get the txtMRNum to interpret the entry as a simple
text
| instead of a numeric?
|
| Thanks in advance!
|
| John
|
|




From: John S. Ford, MD on
Thanks! That's exactly what I was looking for.

John

".Len B" <gonehome(a)internode0.on0.net> wrote in message
news:eHTeK3%236KHA.2220(a)TK2MSFTNGP04.phx.gbl...
> Use this instead
> MsgBox "Is patient " & DLookup("PatientNameLast", "tblPatients",
> "PatientMRNum='" & txtPatientMRNum & "'") & " the patient whose
> chart you are reviewing?"
>
> --
> Len
> ______________________________________________________
> remove nothing for valid email address.
> "John S. Ford, MD" <johnsfordNOSPAMmd(a)hotmail.com> wrote in message
> news:un8jA296KHA.4804(a)TK2MSFTNGP02.phx.gbl...
> |I have table tblPatients with the following fields:
> | PatientIDNum (Autonumber)
> | PatientNameLast (Text)
> | PatientNameFirst (Text)
> | PatientMRNum (Text)
> |
> | Field PatientMRNum is a 7 character medical record number each
> character of
> | which is incidently a numeric character.
> |
> | I have a form with TextBox txtIDNum in which users the patient's MRNum
> | number. A command button on the form has the following code:
> |
> | MsgBox "Is patient " & DLookup("PatientNameLast", "tblPatients",
> | "PatientMRNum=" & txtPatientMRNum) & " the patient whose chart you're
> | reviewing?"
> |
> | Unfortunately, DLookup apparently thinks the contents of
> txtPatientMRNum are
> | integers because this code generates a data mismatch error. The code
> WILL
> | work perfectly if I change the datatype of PatientMRNum in tblPatients
> to
> | Number (but I don't want to do this).
> |
> | Is there a way to get the txtMRNum to interpret the entry as a simple
> text
> | instead of a numeric?
> |
> | Thanks in advance!
> |
> | John
> |
> |
>
>
>
>