Solved

Access String

Posted on 2013-05-23
9
360 Views
Last Modified: 2013-05-23
I would like to remove the first number 1 after the first dash if there are two didgits between the first and second dashes and if the numbers are between 10 and 18. Example

75-11-0350 Before (there are two didgits between the first and second dashs and they are between 10 and 18)
75-1-0350 After

75-10-0350 Before (there are two didgits between the first and second dashs and they are between 10 and 18)
75-0-0350 After

75-19-1216-1031 Before (there are two didgits between the first and second dashs but they are not between 10 and 18)
75-19-1216-1031 After
0
Comment
Question by:shieldsco
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 39191675
Does the field value always begin with xx-  (where x is any character)
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39191692
revise the function that you have with this one


Function FormatData(strInput As String)
      Dim s() As String
      s = Split(strInput, "-")
      s(1) = IIf(Val(s(1)) >= 10 And Val(s(1)) <= 18, Mid(Val(s(1)), 2), Val(s(1)))
      FormatData = Join(s, "-")
End Function
0
 

Author Comment

by:shieldsco
ID: 39191799
It Coverted the following incorrect:

OriginalTBAppropriation      ConvertAppropriation
75-X-0131                         75-0-0131
75-X-0140                                      75-0-0140
75-X-0512                                      75-0-0512
75-X-0943                                      75-0-0943
75-X-0944                                      75-0-0944
75-X-0954                                      75-0-0954
75-X-0956                                      75-0-0956
75-X-5146-001                       75-0-5146-001
75-X-8250-001                       75-0-8250-001
0
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39191822
shieldsco,

you never mentioned that you have ALPHA values after the first dash..

we are not mind readers, so please give all the informations..


so what should be the result in case like that?  should it remain the same?
0
 

Author Comment

by:shieldsco
ID: 39191834
There should not be a change
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39191841
try this

Function FormatData(strInput As String)
      Dim s() As String
      s = Split(strInput, "-")
     
      If IsNumeric(s) Then
              s(1) = IIf(Val(s(1)) >= 10 And Val(s(1)) <= 18, Mid(Val(s(1)), 2), Val(s(1)))
      End If
     
      FormatData = Join(s, "-")
End Function
0
 

Author Comment

by:shieldsco
ID: 39191895
No conversion on the following -- the change however did convert the X values correctly

OriginalTBAppropriation      ConvertAppropriation
75-12-0955                      75-12-0955  Incorrect s/b 75-2-0955


OriginalTBAppropriation      ConvertAppropriation
75-X-0131                                      75-X-0131 correct
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 39191907
oops, missed the (1), use this revised code


Function FormatData(strInput As String)
      Dim s() As String
      s = Split(strInput, "-")
     
      If IsNumeric(s(1)) Then
      s(1) = IIf(Val(s(1)) >= 10 And Val(s(1)) <= 18, Mid(Val(s(1)), 2), Val(s(1)))
      End If
     
      FormatData = Join(s, "-")
End Function
0
 

Author Closing Comment

by:shieldsco
ID: 39191971
Thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question