By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,720 Members | 2,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,720 IT Pros & 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?

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.