469,336 Members | 5,846 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,336 developers. It's quick & easy.

I get type mismatch errors sometimes. Why does Access think it knows what data type a text box control is?

MLH
Runtime error 13 - type mismatch.

I get the above error when I create a text box
control on a form named [UserID] and I run
the following code in a sub on that same form...

If DLookup("[UserID]", "tblUsers", "[UserID]=Forms!Form10!UserID")
Then

tblUsers has a 6-char text field in it named [UserID]. What can Access
be thinking to tell me the data in the textbox and the data in the
table field cannot be compared because of incompatible data types?
This has always bugged me about Access. I believe it should be
possible to compare the string in Forms!Form10!UserID with those
in the table field tblUsers.[UserID].
Nov 13 '05 #1
6 3893
Access is just stubborn, just like you seem to be with your long subject-lines...
I don't think I am the only person having a problem with this ??

Arno R

"MLH" <CR**@NorthState.net> schreef in bericht news:34********************************@4ax.com...
Runtime error 13 - type mismatch.

I get the above error when I create a text box
control on a form named [UserID] and I run
the following code in a sub on that same form...

If DLookup("[UserID]", "tblUsers", "[UserID]=Forms!Form10!UserID")
Then

tblUsers has a 6-char text field in it named [UserID]. What can Access
be thinking to tell me the data in the textbox and the data in the
table field cannot be compared because of incompatible data types?
This has always bugged me about Access. I believe it should be
possible to compare the string in Forms!Form10!UserID with those
in the table field tblUsers.[UserID].

Nov 13 '05 #2
MLH
In case the following helps illustrate my dillemma...

If DLookup("[UserID]", "tblUsers", "[UserID]='bobdsafsie'") Then
....
works just fine - as long as I don't have a user named 'bobdsafsie'.

However, If DLookup("[UserID]", "tblUsers", "[UserID]='mlh") Then
....
fails with the same type mismatch error, as I DO have an 'mlh' user.
I can't help but think this all has something to do with dlookup
itself rather than type mismatches. Ideas anyone?
Nov 13 '05 #3
If DLookup("[UserID]", "tblUsers", "[UserID]=" & Chr$(34) &
Forms!Form10!UserID & Chr$(34))
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"MLH" <CR**@NorthState.net> wrote in message
news:34********************************@4ax.com...
Runtime error 13 - type mismatch.

I get the above error when I create a text box
control on a form named [UserID] and I run
the following code in a sub on that same form...

If DLookup("[UserID]", "tblUsers", "[UserID]=Forms!Form10!UserID")
Then

tblUsers has a 6-char text field in it named [UserID]. What can Access
be thinking to tell me the data in the textbox and the data in the
table field cannot be compared because of incompatible data types?
This has always bugged me about Access. I believe it should be
possible to compare the string in Forms!Form10!UserID with those
in the table field tblUsers.[UserID].

Nov 13 '05 #4
MLH wrote:
In case the following helps illustrate my dillemma...

If DLookup("[UserID]", "tblUsers", "[UserID]='bobdsafsie'") Then
...
works just fine - as long as I don't have a user named 'bobdsafsie'.

However, If DLookup("[UserID]", "tblUsers", "[UserID]='mlh") Then
...
fails with the same type mismatch error, as I DO have an 'mlh' user.
I can't help but think this all has something to do with dlookup
itself rather than type mismatches. Ideas anyone?


Well, what is it comparing to? What is the condition?
True/False/Date/Integer?

I usually compare something to see if it is true or false when a
function like Dlookup doesn't return a boolean. Something like
If IsNull(DLookup("[UserID]", "tblUsers", "[UserID]='mlh")) Then
or
If DLookup("[UserID]", "tblUsers", "[UserID]='mlh") > "" Then

I usually look to create true or false conditions when creating an IF
statement. It appears that, like mine, your version needs a true/false
value to evaluate.
Nov 13 '05 #5
Arno R wrote:
Access is just stubborn, just like you seem to be with your long subject-lines...
I don't think I am the only person having a problem with this ??

Arno R


Plus, MLH has made lots of posts recently on diverse Access topics. I
haven't seen a post by Steve lately. Stubborn seems to connect. I
wonder if MLH is compiling a CD to sell and needs the long Subject
lines as a way to index threads... :-) :-)

James A. Fortune

Nov 13 '05 #6
MLH
Good suggestions, Salad. Thanks for the pointers.

Well, what is it comparing to? What is the condition?
True/False/Date/Integer?

I usually compare something to see if it is true or false when a
function like Dlookup doesn't return a boolean. Something like
If IsNull(DLookup("[UserID]", "tblUsers", "[UserID]='mlh")) Then
or
If DLookup("[UserID]", "tblUsers", "[UserID]='mlh") > "" Then

I usually look to create true or false conditions when creating an IF
statement. It appears that, like mine, your version needs a true/false
value to evaluate.


Nov 13 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Tongu? Yumruk | last post: by
1 post views Thread by Mark | last post: by
18 posts views Thread by Marina | last post: by
3 posts views Thread by Martin Lacoste | last post: by
3 posts views Thread by Jake | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.