data type mismatch in criteria expression

S

scubadiver

I have the following query as the source for a combo and I am getting the
above error message.

SELECT tble_employee.Employee, tble_employee.Dept
FROM tble_employee
WHERE (((tble_employee.Dept)<>"Operations") AND ((tble_employee.Work)=True))
ORDER BY tble_employee.Dept, Mid([Employee],InStr([Employee]," ")+1);
 
A

Andy Hull

Hi

On the face of it the SQL looks ok.

From the error message I would want to double check the datatype of the
following...

tble_employee.Dept - Is this really text? or is it an integer foreign key?
tble_employee.Work - Confirm this is yes/no
tbl_employee.Employee - Confirm this is text


Andy Hull
 
S

scubadiver

Just to give you some info "tble_employee" is a link table from another
database. Could this be the problem?

tble_employee.Dept is a text field
tble_employee.Work is a "yes/no" field
tbl_employee.Employee is a text field

thanks

Jeff Boyce said:
To follow up on Andy's response, if your [Dept] field is defined as a
"Lookup" data type, the table stores one value but displays another. Check
there, too.

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

scubadiver said:
I have the following query as the source for a combo and I am getting the
above error message.

SELECT tble_employee.Employee, tble_employee.Dept
FROM tble_employee
WHERE (((tble_employee.Dept)<>"Operations") AND ((tble_employee.Work)=True))
ORDER BY tble_employee.Dept, Mid([Employee],InStr([Employee]," ")+1);
 
J

Jeff Boyce

I don't see how.

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

scubadiver said:
Just to give you some info "tble_employee" is a link table from another
database. Could this be the problem?

tble_employee.Dept is a text field
tble_employee.Work is a "yes/no" field
tbl_employee.Employee is a text field

thanks

Jeff Boyce said:
To follow up on Andy's response, if your [Dept] field is defined as a
"Lookup" data type, the table stores one value but displays another. Check
there, too.

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

scubadiver said:
I have the following query as the source for a combo and I am getting the
above error message.

SELECT tble_employee.Employee, tble_employee.Dept
FROM tble_employee
WHERE (((tble_employee.Dept)<>"Operations") AND ((tble_employee.Work)=True))
ORDER BY tble_employee.Dept, Mid([Employee],InStr([Employee]," ")+1);
 
G

Gary Walter

scubadiver said:
I have the following query as the source for a combo and I am getting the
above error message.

SELECT tble_employee.Employee, tble_employee.Dept
FROM tble_employee
WHERE (((tble_employee.Dept)<>"Operations") AND
((tble_employee.Work)=True))
ORDER BY tble_employee.Dept, Mid([Employee],InStr([Employee]," ")+1);

In addition to other sage help you have received...

1) doubtful since error says "criteria," but
as written, if [Employee] is NULL,
InStr will choke (not necessarily same
error, but maybe it filters up to error
you are receiving). Easy test, use:

Mid(employee,InStr(employee & ""," ")+1)

2) is there a chance you are assigning this SQL
to your combo in code by creating a string?
The reason I ask is that I do that alot and
sometimes forget to use single quotes instead
of double quotes, and end up with data type
mismatch error when execute query string.

3) I notice your signature here before so please
ignore if this is too basic diag 101, but in form
design, property of your combo recordsource,
you can click on elispses command button to
open sql in query designer where you can easily
remove one or the other criteria and click on
View icon to test if either is causing error...

good luck,

gary
 
J

Joe Jones

I have a similar situation where the criteria field is a lookup. But how do I deal with that? In the table of its origin it is a number but I still get the error message., Any help would be appreciated.



Jeff Boyce wrote:

To follow up on Andy's response, if your [Dept] field is defined as a"Lookup"
08-Oct-07

To follow up on Andy's response, if your [Dept] field is defined as a
"Lookup" data type, the table stores one value but displays another. Check
there, too.

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

((tble_employee.Work)=True))

Previous Posts In This Thread:

data type mismatch in criteria expression
I have the following query as the source for a combo and I am getting the
above error message.

SELECT tble_employee.Employee, tble_employee.Dept
FROM tble_employee
WHERE (((tble_employee.Dept)<>"Operations") AND ((tble_employee.Work)=True))
ORDER BY tble_employee.Dept, Mid([Employee],InStr([Employee]," ")+1);

HiOn the face of it the SQL looks ok.
Hi

On the face of it the SQL looks ok.

From the error message I would want to double check the datatype of the
following...

tble_employee.Dept - Is this really text? or is it an integer foreign key?
tble_employee.Work - Confirm this is yes/no
tbl_employee.Employee - Confirm this is text


Andy Hull


:

To follow up on Andy's response, if your [Dept] field is defined as a"Lookup"
To follow up on Andy's response, if your [Dept] field is defined as a
"Lookup" data type, the table stores one value but displays another. Check
there, too.

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

((tble_employee.Work)=True))

Just to give you some info "tble_employee" is a link table from another
Just to give you some info "tble_employee" is a link table from another
database. Could this be the problem?

tble_employee.Dept is a text field
tble_employee.Work is a "yes/no" field
tbl_employee.Employee is a text field

thanks

:

I don't see how.-- RegardsJeff Boycewww.InformationFutures.
I don't see how.

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Check
the

Re: data type mismatch in criteria expression
:

In addition to other sage help you have received...

1) doubtful since error says "criteria," but
as written, if [Employee] is NULL,
InStr will choke (not necessarily same
error, but maybe it filters up to error
you are receiving). Easy test, use:

Mid(employee,InStr(employee & ""," ")+1)

2) is there a chance you are assigning this SQL
to your combo in code by creating a string?
The reason I ask is that I do that alot and
sometimes forget to use single quotes instead
of double quotes, and end up with data type
mismatch error when execute query string.

3) I notice your signature here before so please
ignore if this is too basic diag 101, but in form
design, property of your combo recordsource,
you can click on elispses command button to
open sql in query designer where you can easily
remove one or the other criteria and click on
View icon to test if either is causing error...

good luck,

gary


Submitted via EggHeadCafe - Software Developer Portal of Choice
ASP.NET All Rows Editable AJAX-Enabled DataGrid
http://www.eggheadcafe.com/tutorial...74-c23e95eb6f00/aspnet-all-rows-editable.aspx
 
J

Jeff Boyce

Any chance the field is defined as a Lookup datatype in the table in
question? (review my comments below)

I'm not sure what you mean by "where the criterion field is a lookup" --
could you explain that a bit more?

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.

I have a similar situation where the criteria field is a lookup. But how do
I deal with that? In the table of its origin it is a number but I still get
the error message., Any help would be appreciated.



Jeff Boyce wrote:

To follow up on Andy's response, if your [Dept] field is defined as
a"Lookup"
08-Oct-07

To follow up on Andy's response, if your [Dept] field is defined as a
"Lookup" data type, the table stores one value but displays another.
Check
there, too.

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

((tble_employee.Work)=True))

Previous Posts In This Thread:

data type mismatch in criteria expression
I have the following query as the source for a combo and I am getting the
above error message.

SELECT tble_employee.Employee, tble_employee.Dept
FROM tble_employee
WHERE (((tble_employee.Dept)<>"Operations") AND
((tble_employee.Work)=True))
ORDER BY tble_employee.Dept, Mid([Employee],InStr([Employee]," ")+1);

HiOn the face of it the SQL looks ok.
Hi

On the face of it the SQL looks ok.

From the error message I would want to double check the datatype of the
following...

tble_employee.Dept - Is this really text? or is it an integer foreign
key?
tble_employee.Work - Confirm this is yes/no
tbl_employee.Employee - Confirm this is text


Andy Hull


:

To follow up on Andy's response, if your [Dept] field is defined as
a"Lookup"
To follow up on Andy's response, if your [Dept] field is defined as a
"Lookup" data type, the table stores one value but displays another.
Check
there, too.

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

((tble_employee.Work)=True))

Just to give you some info "tble_employee" is a link table from another
Just to give you some info "tble_employee" is a link table from another
database. Could this be the problem?

tble_employee.Dept is a text field
tble_employee.Work is a "yes/no" field
tbl_employee.Employee is a text field

thanks

:

I don't see how.-- RegardsJeff Boycewww.InformationFutures.
I don't see how.

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Check
the

Re: data type mismatch in criteria expression
:

In addition to other sage help you have received...

1) doubtful since error says "criteria," but
as written, if [Employee] is NULL,
InStr will choke (not necessarily same
error, but maybe it filters up to error
you are receiving). Easy test, use:

Mid(employee,InStr(employee & ""," ")+1)

2) is there a chance you are assigning this SQL
to your combo in code by creating a string?
The reason I ask is that I do that alot and
sometimes forget to use single quotes instead
of double quotes, and end up with data type
mismatch error when execute query string.

3) I notice your signature here before so please
ignore if this is too basic diag 101, but in form
design, property of your combo recordsource,
you can click on elispses command button to
open sql in query designer where you can easily
remove one or the other criteria and click on
View icon to test if either is causing error...

good luck,

gary


Submitted via EggHeadCafe - Software Developer Portal of Choice
ASP.NET All Rows Editable AJAX-Enabled DataGrid
http://www.eggheadcafe.com/tutorial...74-c23e95eb6f00/aspnet-all-rows-editable.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top