473,385 Members | 1,331 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 4210
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: lawrence | last post by:
I'm trying to read up on the rfc's that govern form inputs. Much of what I'm reading is stuff I didn't know before and some of it is alarming. This one left with me questions: ...
5
by: Tongu? Yumruk | last post by:
I have a little proposal about type checking in python. I'll be glad if you read and comment on it. Sorry for my bad english (I'm not a native English speaker) A Little Stricter Typing in Python...
1
by: Mark | last post by:
Hi - I tried this in VS.Net, and also in the Web Matrix code below: - but I am getting a type mismatch error. The sql statement runs perfectly from within the Access Query Designer. Can anyone...
18
by: Marina | last post by:
Hi, if anyone can help on this, please! This is driving me crazy. I have a user control hierarchy several levels deep that derive for UserControl (windows). The class that is at the top level,...
3
by: Martin Lacoste | last post by:
Is there some issue with using too many left/right/mid/len functions in queries? Depending on the usage, they work fine, but... then there's here: SELECT Master_CAO.Incipit,...
3
by: Jake | last post by:
I am currently trying to create my own Point Of Sale software for my retail store. I wrote the program with the UPC field as Long integer. When I started to add the products by UPC code, I got a...
4
by: bleighfield | last post by:
Hi everyone Hope someone can help with this one.. Background: I work in vehicle fleet, I have built something to 'predict' when a car/van service is due (it's fairly simple, calculates...
2
by: technocraze | last post by:
Hi guys, Implementations application & programming environ MS Acess + Visual Basic Table fields Serialno (pk) - Auto number StudentId - text Course - text intake - number
9
by: nixonmg | last post by:
When the Command Button "Notify" is clicked, I am wanting to send out an email to the user with appropriate information in the email (works great), check the "Notified" check box (does not work), and...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.