data type mismatch in crieria expression

H

Hal

help.....!!!!

I am trying to group my data based upon te results of calling a function:

SELECT qbranchgoalsalegrouped.PROMOID, qbranchgoalsalegrouped.PROMOPHASEID,
goalgroup([qbranchgoalsalegrouped]![percentofsales]) AS Expr1
FROM qbranchgoalsalegrouped
GROUP BY qbranchgoalsalegrouped.PROMOID,
qbranchgoalsalegrouped.PROMOPHASEID,
goalgroup([qbranchgoalsalegrouped]![percentofsales]);

The function returns an integer fromm 0 to 5.

thanks
 
D

Douglas J. Steele

How is GoalGroup defined? Specifically, how are the parameters declared? If,
for example, you've declared a parameter to be Long Integer and the field in
the table that's being passed is Integer, you can run into problems. (You'll
also run into problems if you've declared a parameter to be anything but
Variant and the value for the field being passed can be Null)
 
H

Hal

Public Function goalgroup(igoalpercent As Double) As Integer
If igoalpercent >= 1 Then goalgroup = 1 Else
If igoalpercent >= 0.8 And igoalpercent < 1 Then goalgroup = 2 Else
If igoalpercent >= 0.5 And igoalpercent < 0.8 Then goalgroup = 3 Else
If igoalpercent >= 0.2 And igoalpercent < 0.5 Then goalgroup = 4 Else
If igoalpercent < 0.2 And igoalpercent > 0 Then goalgroup = 5 Else goalgroup
= 0


End Function

Douglas J. Steele said:
How is GoalGroup defined? Specifically, how are the parameters declared? If,
for example, you've declared a parameter to be Long Integer and the field in
the table that's being passed is Integer, you can run into problems. (You'll
also run into problems if you've declared a parameter to be anything but
Variant and the value for the field being passed can be Null)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Hal said:
help.....!!!!

I am trying to group my data based upon te results of calling a function:

SELECT qbranchgoalsalegrouped.PROMOID,
qbranchgoalsalegrouped.PROMOPHASEID,
goalgroup([qbranchgoalsalegrouped]![percentofsales]) AS Expr1
FROM qbranchgoalsalegrouped
GROUP BY qbranchgoalsalegrouped.PROMOID,
qbranchgoalsalegrouped.PROMOPHASEID,
goalgroup([qbranchgoalsalegrouped]![percentofsales]);

The function returns an integer fromm 0 to 5.

thanks
 
D

Douglas J. Steele

And what about the field percentofsales? Is qbranchgoalsalegrouped a table
or a query? If it's a query, is percentofsales a calculated field? If so,
try wrapping the CDbl function around it, to ensure that it's been seen as a
Double.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Hal said:
Public Function goalgroup(igoalpercent As Double) As Integer
If igoalpercent >= 1 Then goalgroup = 1 Else
If igoalpercent >= 0.8 And igoalpercent < 1 Then goalgroup = 2 Else
If igoalpercent >= 0.5 And igoalpercent < 0.8 Then goalgroup = 3 Else
If igoalpercent >= 0.2 And igoalpercent < 0.5 Then goalgroup = 4 Else
If igoalpercent < 0.2 And igoalpercent > 0 Then goalgroup = 5 Else
goalgroup
= 0


End Function

Douglas J. Steele said:
How is GoalGroup defined? Specifically, how are the parameters declared?
If,
for example, you've declared a parameter to be Long Integer and the field
in
the table that's being passed is Integer, you can run into problems.
(You'll
also run into problems if you've declared a parameter to be anything but
Variant and the value for the field being passed can be Null)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Hal said:
help.....!!!!

I am trying to group my data based upon te results of calling a
function:

SELECT qbranchgoalsalegrouped.PROMOID,
qbranchgoalsalegrouped.PROMOPHASEID,
goalgroup([qbranchgoalsalegrouped]![percentofsales]) AS Expr1
FROM qbranchgoalsalegrouped
GROUP BY qbranchgoalsalegrouped.PROMOID,
qbranchgoalsalegrouped.PROMOPHASEID,
goalgroup([qbranchgoalsalegrouped]![percentofsales]);

The function returns an integer fromm 0 to 5.

thanks
 
Top