Attempting to remove first number from specific numbers in report!!1

  • Thread starter Thread starter Ascheman
  • Start date Start date
A

Ascheman

I am trying to check a field to see if the the first
number is a 2 and if it is then to see if the last item in
the field is and A or a B .... if its an a or b then
select only the 5 right characters and if its not then
select the right 4 characters... I know that my code is
close but as to where to place it I am at a loss. Here is
the code I have to this point.
<cod>
if left(unitnumber,1) = 2 and right(unitnumber,1) = A or
right(unitnumber,1) = b then
unitnumber = right(unitnumber,5)
else
unitnumber = right(unitnumber,4)
end if
</code>

If anyone can help me to get this to working it would be
greatly appreciated.

Thanks in advance.
C. Ascheman
 
I am trying to check a field to see if the the first
number is a 2 and if it is then to see if the last item in
the field is and A or a B .... if its an a or b then
select only the 5 right characters and if its not then
select the right 4 characters... I know that my code is
close but as to where to place it I am at a loss. Here is
the code I have to this point.
<cod>
if left(unitnumber,1) = 2 and right(unitnumber,1) = A or
right(unitnumber,1) = b then
unitnumber = right(unitnumber,5)
else
unitnumber = right(unitnumber,4)
end if
</code>

If anyone can help me to get this to working it would be
greatly appreciated.

Thanks in advance.
C. Ascheman

Add an Unbound control to the report.

Place this code in the Detail Format event:
Note the addition of parentheses around the second set of criteria,
and the use of quotes around the all the criteria characters (they are
all text, though the 2 is optional).

if left(unitnumber,1) = "2" and (right(unitnumber,1) = "A" or
right(unitnumber,1) ="b") then
[UnboundControlName] = right(unitnumber,5)
else
[UnboundControlName] = right(unitnumber,4)
end if

You can also do this directly in the unbound control, without using
any code event.
As control source for the Unbound control, write:

=IIf(left(unitnumber,1) = "2" and (right(unitnumber,1) = "A" or
right(unitnumber,1) = "b"),right(unitnumber,5),right(unitnumber,4))
 
Back
Top