#Error message in Switch statement

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

Guest

I have the following switch statement associated with the Control Source
property of a field in my report:
=Switch([RcvSpd]=0,"Low",[RcvSpd]=1,"High",[RcvSpd]=2,"Auto")

When I run the report, I get #Error displayed for that field.
If I replace the switch with simply "RcvSpd" (without the quotes) it reports
the numeric value in that field properly. The only values in the records are
1 and 2. There aren't any null values and there aren't even any fields set
to zero.

I've used this exact same switch on other reports and it works. I've
checked to ensure that the query this report is based on really has the
RcvSpd field in it.

Can anyone help? Thanks!
 
Check the name of the text box. It is probably "RcvSpd" which should be
changed.
You might also try:
=Choose([RcvSpd]+1,"Low","High","Auto")
 
Thank you Duane, that helped to some extent.
I tried the Choose statement and it worked. However then it stopped working
and displayed #Error. I looked at the text box name. I presume you are
refering to the "Name" property which is displayed in the property sheet for
the field I'm trying to get working. Yes it was called RcvSpd. but when I
changed it to RcvSpd1, it automatically changed the Choose statement to have
[RcvSpd1] instead of [RcvSpd]! And that's not right!

At one point I had both the Switch statement and the Choose statement
working and then managed to get both of them to fail and could not fix them.
Note: I keep cut and pasting in the strings (with Switch or Choose) in order
to ensure that it's not a typo.

I finally gave up, deleted the entire report and started over. I got the
choose statement to work but am now afraid to do anything else to the report
because I still don't understand WHY it sometimes just ceases to function.
Where would be a good place to read about how Switch and Choose and the
Control Source property work? I am very new to Access. I've tried the Help
files but the information is minimal - either that or I'm searching for the
wrong thing.

Thanks again!

Duane Hookom said:
Check the name of the text box. It is probably "RcvSpd" which should be
changed.
You might also try:
=Choose([RcvSpd]+1,"Low","High","Auto")


--
Duane Hookom
MS Access MVP
--

Wings said:
I have the following switch statement associated with the Control Source
property of a field in my report:
=Switch([RcvSpd]=0,"Low",[RcvSpd]=1,"High",[RcvSpd]=2,"Auto")

When I run the report, I get #Error displayed for that field.
If I replace the switch with simply "RcvSpd" (without the quotes) it
reports
the numeric value in that field properly. The only values in the records
are
1 and 2. There aren't any null values and there aren't even any fields
set
to zero.

I've used this exact same switch on other reports and it works. I've
checked to ensure that the query this report is based on really has the
RcvSpd field in it.

Can anyone help? Thanks!
 
Do you have a field in your report's record source name RcvSpd1? Did you
check both the Name and Control Source properties?

Name: txtRcvSpd
Control Source: =Choose([RcvSpd]+1,"Low","High","Auto")


--
Duane Hookom
MS Access MVP


Wings said:
Thank you Duane, that helped to some extent.
I tried the Choose statement and it worked. However then it stopped
working
and displayed #Error. I looked at the text box name. I presume you are
refering to the "Name" property which is displayed in the property sheet
for
the field I'm trying to get working. Yes it was called RcvSpd. but when
I
changed it to RcvSpd1, it automatically changed the Choose statement to
have
[RcvSpd1] instead of [RcvSpd]! And that's not right!

At one point I had both the Switch statement and the Choose statement
working and then managed to get both of them to fail and could not fix
them.
Note: I keep cut and pasting in the strings (with Switch or Choose) in
order
to ensure that it's not a typo.

I finally gave up, deleted the entire report and started over. I got the
choose statement to work but am now afraid to do anything else to the
report
because I still don't understand WHY it sometimes just ceases to function.
Where would be a good place to read about how Switch and Choose and the
Control Source property work? I am very new to Access. I've tried the Help
files but the information is minimal - either that or I'm searching for
the
wrong thing.

Thanks again!

Duane Hookom said:
Check the name of the text box. It is probably "RcvSpd" which should be
changed.
You might also try:
=Choose([RcvSpd]+1,"Low","High","Auto")


--
Duane Hookom
MS Access MVP
--

Wings said:
I have the following switch statement associated with the Control Source
property of a field in my report:
=Switch([RcvSpd]=0,"Low",[RcvSpd]=1,"High",[RcvSpd]=2,"Auto")

When I run the report, I get #Error displayed for that field.
If I replace the switch with simply "RcvSpd" (without the quotes) it
reports
the numeric value in that field properly. The only values in the
records
are
1 and 2. There aren't any null values and there aren't even any fields
set
to zero.

I've used this exact same switch on other reports and it works. I've
checked to ensure that the query this report is based on really has the
RcvSpd field in it.

Can anyone help? Thanks!
 
Back
Top