Full Version: Select Case code
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
minnesota1972
Hi to all

My select code doesn't seem to work.

Select Case Me!DAName.Value
Case is = "#"
[DAName] = "00" + [DAName]
Case Is = "##"
[DAName] = "0" + [DAName]
End Select

I'm trying to reformat my numbers. (The hard way). I've got it to work with one case as an if statement
If [DAName] Like "#" Then
[DAName] = "00" + [DAName]
End If

What's wrong with my select case? I know it's probably somewhere in the
Select Case Me!DAName.Value
or it might be in the
Case is = "#"

John
AJS
Well, your Case Is statements aren't checking for a single digit -- you'd need to use Like for that, as you found out. I take it this is bound to a text field. Otherwise, leading zeroes would not matter.

Why don't you simply use something like:
CODE
If isNumeric(Me.DAName) then
   Me.DAName = Format(Me.DAName, "000")
End If


This would change any numeric values to at least three digits, while leaving Non-numeric values unchanged.

hope this helps
-AJ
minnesota1972
Hi Evil Skeleton King!

WOW!

Thanks for the help. I didn't know about that "isnumeric" thing. That actually works a lot better! I bow to the Evil Skeleton King. All hail the Evil Skeleton King! That sure is some real fine tastey code from the Evil Skeleton King!

Seriously, thanks

John
erwardell
Why not just go into the table and in the format section of the field property put in 000. This will effect all entries in that field.
AJS
You're welcome. I'm glad to help. and glad it works for you. I was just kinda guessing as to what you needed.

-AJ
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.