Using Mid function

C

CD Tom

I don't know why I'm having problems with this function. Here's what I want
to do. I have a variable called VCDivision it can contain up to 3 characters
example L1, LS1, L2, LS2 if the variable contains the L1 and it is required
to be changed to an Lx where x = a number from 2 - 5. Here's the code I
have, I'm using a 2 position field.
VX = Mid(VCdivision, 2, 1) = VNewnumber where the Vnewnumber is say the 2.
What I get in the VX is a False. Why do I get a false instead of L2? This
is probably very simple but I can't get it to work. Thanks for any help.
 
D

Douglas J. Steele

If I'm reading your post correctly, you have a line of code

VX = Mid(VCdivision, 2, 1) = VNewnumber

What that code does is take the 2nd digit from what's currently in
VCDivision, and compares it to whatever's in VNewnumber. It then stores the
results of that comparison (i.e. True or Value) in VX.

Since you're trying to set the second character of the string (and the first
character is obviously going to be L, since you're only doing this when
VCDivision is L1), simply use:

VX = "L" & VNewnumber
 
C

CD Tom

Thanks, I did figure it out, I really appreciate all the help you guys give
to us learning Access.
 
Top