View Full Version : Replacing Digits/DLookup


keeswijn
04-24-2002, 01:04 PM
What is the best way to replace 2 digits within a number on a form ?.

I have a form on which the user will enter a 10 digit number (Digits 1-3 = Country, Digits 4-5 = City, Digits 6-10 = Department).
The only digits which I want to change are 4 and 5 depending on the 10 digit number input by the user.
EG. If the user enters in 6043710036, I want 6044810036 to be returned. It is not practical to make a table of all valid entries which a user may make and the corresponding value to be returned.

I think What I am after is a combination of :

Left()+ Dlookup + Right() but am not sure how to do that.

TIA

Jack Cowley
04-24-2002, 01:20 PM
Dim Answer As Integer
Dim a As Integer
a = Mid(MyNumber,4,2)

Select Case a
case 42
Answer = Left(MyNumber, 3)& 52 & Right(MyNumber, 5)
case 43
Answer = Left(MyNumber, 3)& 57 & Right(MyNumber, 5)
etc...
End Select

[This message has been edited by Jack Cowley (edited 04-24-2002).]