Data Type Mismatch??? big problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am getting an error returned as Data type mismatch when I try and use a
command button in a form to open a report to a single record. The report is
based on a query that pulls up the same "Electrical Work Order" as the form
but the "combo29" brings it up directly from the table, and is my filter for
changing records in the table easily. The error doesn't give any further
explanation, and I have used this identical code at least 40 other times,
with positive results. Anyone else ever have this problem? Help would be
greatly appreciated. I have posted the code I'm using below

DoCmd.OpenReport "Cost Electrical Work Orders1", acPreview, , "[Electrical
Work Order] = """ & Me![Combo29] & """"
End Sub

Thanks
Dustin
 
Open the table in design view, and see what is the data type of the
[Electrical Work Order] field.

If it is a Number type (not a Text type), lose the extra quotes, i.e.:
DoCmd.OpenReport "Cost Electrical Work Orders1", acViewPreview, , _
"[Electrical Work Order] = " & Me![Combo29]

If that does not work, there is a problem with the Row Source of the combo,
such that its Bound Column is not the same type of field as your [Electrical
Work Order] field.
 
Yes it is a number value and that code change gets rid of the data type
mismatch, but now I get an error saying there is an extra ) in query
expression '([Electrical Work Order]=)'. Could this be because my report is
based on a query but my form with the command button is directly sourced from
the same table but not the query. It is the same record source in both
instances but the query calls up the number then the report brings it from
that query.

Confused
Dustin


Allen Browne said:
Open the table in design view, and see what is the data type of the
[Electrical Work Order] field.

If it is a Number type (not a Text type), lose the extra quotes, i.e.:
DoCmd.OpenReport "Cost Electrical Work Orders1", acViewPreview, , _
"[Electrical Work Order] = " & Me![Combo29]

If that does not work, there is a problem with the Row Source of the combo,
such that its Bound Column is not the same type of field as your [Electrical
Work Order] field.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Dustin said:
I am getting an error returned as Data type mismatch when I try and use a
command button in a form to open a report to a single record. The report
is
based on a query that pulls up the same "Electrical Work Order" as the
form
but the "combo29" brings it up directly from the table, and is my filter
for
changing records in the table easily. The error doesn't give any further
explanation, and I have used this identical code at least 40 other times,
with positive results. Anyone else ever have this problem? Help would be
greatly appreciated. I have posted the code I'm using below

DoCmd.OpenReport "Cost Electrical Work Orders1", acPreview, , "[Electrical
Work Order] = """ & Me![Combo29] & """"
End Sub

Thanks
Dustin
 
The problem is that there is no number at all in the expression, so JET
found a closing quote before anything.

This would happen where the combo is blank.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Dustin said:
Yes it is a number value and that code change gets rid of the data type
mismatch, but now I get an error saying there is an extra ) in query
expression '([Electrical Work Order]=)'. Could this be because my report
is
based on a query but my form with the command button is directly sourced
from
the same table but not the query. It is the same record source in both
instances but the query calls up the number then the report brings it from
that query.

Confused
Dustin


Allen Browne said:
Open the table in design view, and see what is the data type of the
[Electrical Work Order] field.

If it is a Number type (not a Text type), lose the extra quotes, i.e.:
DoCmd.OpenReport "Cost Electrical Work Orders1", acViewPreview, , _
"[Electrical Work Order] = " & Me![Combo29]

If that does not work, there is a problem with the Row Source of the
combo,
such that its Bound Column is not the same type of field as your
[Electrical
Work Order] field.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Dustin said:
I am getting an error returned as Data type mismatch when I try and use
a
command button in a form to open a report to a single record. The
report
is
based on a query that pulls up the same "Electrical Work Order" as the
form
but the "combo29" brings it up directly from the table, and is my
filter
for
changing records in the table easily. The error doesn't give any
further
explanation, and I have used this identical code at least 40 other
times,
with positive results. Anyone else ever have this problem? Help would
be
greatly appreciated. I have posted the code I'm using below

DoCmd.OpenReport "Cost Electrical Work Orders1", acPreview, ,
"[Electrical
Work Order] = """ & Me![Combo29] & """"
End Sub

Thanks
Dustin
 
Yes That was the problem, sometimes I love feeling dumb
Thanks Allen I owe you one.
--
Dustin


Allen Browne said:
The problem is that there is no number at all in the expression, so JET
found a closing quote before anything.

This would happen where the combo is blank.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Dustin said:
Yes it is a number value and that code change gets rid of the data type
mismatch, but now I get an error saying there is an extra ) in query
expression '([Electrical Work Order]=)'. Could this be because my report
is
based on a query but my form with the command button is directly sourced
from
the same table but not the query. It is the same record source in both
instances but the query calls up the number then the report brings it from
that query.

Confused
Dustin


Allen Browne said:
Open the table in design view, and see what is the data type of the
[Electrical Work Order] field.

If it is a Number type (not a Text type), lose the extra quotes, i.e.:
DoCmd.OpenReport "Cost Electrical Work Orders1", acViewPreview, , _
"[Electrical Work Order] = " & Me![Combo29]

If that does not work, there is a problem with the Row Source of the
combo,
such that its Bound Column is not the same type of field as your
[Electrical
Work Order] field.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

I am getting an error returned as Data type mismatch when I try and use
a
command button in a form to open a report to a single record. The
report
is
based on a query that pulls up the same "Electrical Work Order" as the
form
but the "combo29" brings it up directly from the table, and is my
filter
for
changing records in the table easily. The error doesn't give any
further
explanation, and I have used this identical code at least 40 other
times,
with positive results. Anyone else ever have this problem? Help would
be
greatly appreciated. I have posted the code I'm using below

DoCmd.OpenReport "Cost Electrical Work Orders1", acPreview, ,
"[Electrical
Work Order] = """ & Me![Combo29] & """"
End Sub

Thanks
Dustin
 

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

Back
Top