Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Follow Up ? -> 2 Tables Comparison

Posted on 2004-08-03
9
Medium Priority
?
377 Views
Last Modified: 2009-12-16
Please See:
http://www.experts-exchange.com/Databases/MS_Access/Q_21059341.html
http://www.experts-exchange.com/Databases/MS_Access/Q_21054826.html
http://www.experts-exchange.com/Databases/MS_Access/Q_21054509.html
------------------------------------------------------------------------------------------

Last time i promiss, I want to change the new code (See Below) to select 3 characters (instead of 2) to compare after the numbers... again ignoring spaces and caps...
Please see the previous questions to understand what it is I am trying to accomplish here...
Thanks In advance
-BassKozz

<<<START CODE>>>
Function Val1Char(strInput As String) As String
Dim i As Integer
Dim StrLenght As Integer
strInput = Replace(strInput, " ", "")
For i = 1 To Len(strInput)
    If Not IsNumeric(Mid(strInput, i, 1)) Then
         StrLenght = i + 1
         Exit For    'exit after finding the first number from left
    End If
Next i

Val1Char = IIf(StrLenght = 0, "na", Left(strInput, StrLenght))

End Function
<<<END CODE>>>
0
Comment
Question by:basskozz
[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
  • 5
  • 4
9 Comments
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 11711474
For three characters after first number use:

Function Val1Char(strInput As String) As String
Dim i As Integer
Dim StrLenght As Integer
strInput = Replace(strInput, " ", "")
For i = 1 To Len(strInput)
    If IsNumeric(Mid(strInput, i, 1)) Then
         StrLenght = i + 1
         Exit For    'exit after finding the first number from left
    End If
Next i

Val1Char = IIf(StrLenght = 0, "na", Mid(strInput, StrLenght , 3))

End Function
0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 11711506
Last example will pick:

3RTUX     first number is 3, therefor will return RTU

356RTUX     first number is 3, therefor will return 56R

----------------------------
To select RTU  form both examples, I guess what you are asking for, try:

Function Val1Char(strInput As String) As String
Dim i As Integer
Dim StrLenght As Integer
strInput = Replace(strInput, " ", "")
For i = 1 To Len(strInput)
    If Not IsNumeric(Mid(strInput, i, 1)) Then
         StrLenght = i
         Exit For    'exit after finding the first number from left
    End If
Next i

Val1Char = IIf(StrLenght = 0, "na", Mid(strInput, StrLenght , 3))

End Function
------------
Provided that your string never starts with text characters.  

Mike
0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 11711525
Well, if it start with string, like:

RTUX   you will get RTU using second post.
----------
If you are looking to extrach RUT from say:

ABC12RUTX

Meaning, there is going to be some numbers always, a third code is required to do that.  I will wait for your response.

Mike
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:basskozz
ID: 11711683
Example of what I would like it to do...

123east = 123 easxtern (123eas=123eas)
123 east = 123easxtern (123eas=123eas)
222 Smith = 222 Smitty (222smi=222smi)


Examples of what NOT to collect or match....

111 east =/ 123 east  (because numbers don't match)
111 east =/ 111 eat   (because "eas" doesn't equal "eat")

0
 
LVL 34

Accepted Solution

by:
Mike Eghtebas earned 2000 total points
ID: 11712152
Function Val1Char(strInput As String) As String
Dim i As Integer
Dim StrLenght As Integer
strInput = Replace(strInput, " ", "")
For i = 1 To Len(strInput)
    If Not IsNumeric(Mid(strInput, i, 1)) Then
         StrLenght = i
         Exit For    'exit after finding the first number from left
    End If
Next i

Val1Char = IIf(StrLenght = 0, "na", Left(strInput, (StrLenght , 2)))

End Function

Above function will return:

123east = 123 easxtern (123eas=123eas)
123 east = 123easxtern (123eas=123eas)
222 Smith = 222 Smitty (222smi=222smi)


Examples of what NOT to collect or match....

111 east  ---------> 111eas
111east   ---------> 111eas
123 east  ---------> 123eas
123east   ---------> 123eas
111 eat   ---------> 111eat
111eat    ---------> 111eat

Comparing them is a different story.  It ought to be handled with a the query.

Mike
0
 

Author Comment

by:basskozz
ID: 11715305
Mike,

Syntax Error :
Val1Char = IIf(StrLenght = 0, "na", Left(strInput, (StrLenght , 2)))

0
 

Author Comment

by:basskozz
ID: 11715513
It might be easier to see what the code does in my Database... so I have put up links to the database...

http://home.earthlink.net/~chrisrutter/

<<<OR>>>

http://home.earthlink.net/~chrisrutter/MLS%20Active%20Search.mdb
http://home.earthlink.net/~chrisrutter/MLS%20Active%20Search.rar


*.mdb file = 2056kb
*.rar file   = 276kb

0
 
LVL 34

Assisted Solution

by:Mike Eghtebas
Mike Eghtebas earned 2000 total points
ID: 11717069
change , with + in

Val1Char = IIf(StrLenght = 0, "na", Left(strInput, (StrLenght + 2)))
0
 

Author Comment

by:basskozz
ID: 11717465
It works,
Thanks Mike

-BassKozz
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

715 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