Solved

Foxpro - Searching for numbers in separate column

Posted on 2016-10-03
8
40 Views
Last Modified: 2016-11-06
Here is my issue:  I have a dbf table with following fields:
Part Number               Orig Information
123                                Seat, 123, Viton
456                                Seat, 04567, Viton

I am trying to flag a field when the Part Number (123) is identified in the original field so that I can easily find items that need to be corrected.  The 456 is incorrectly entered into the Part Number field, it should be 04567 but I need to identify the ones that we need to look at.
0
Comment
Question by:appelonia21
[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
8 Comments
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 41826329
Is the Orig Information always in that format?
If so you can do something like
select * from table1 where [part number] <> mid([Orig Information],7,instr(7,[Orig Information],",")-7)

Open in new window

0
 

Author Comment

by:appelonia21
ID: 41826410
No unfortunately it isn't.  It is a raw data field and can be in any format, I just want to be able to search within it for the match
0
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 41826431
@I just want to be able to search within it for the match

Are there any sure delimiters? If not you should create some code to check into any string to strip out the value to match

For example this query will select every record where part number is contained into Orig Information
select * from table1 where [Orig Information] LIKE "*"+[Part Number]+"*"

Open in new window

but if let's say every part number into the Orig Information is in format [space]Part No.[comma] (that is   " 04567,") then you could use a query like
select * from table1 where [Orig Information] not LIKE "* "+[Part Number]+",*"

Open in new window

0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
LVL 38

Expert Comment

by:PatHartman
ID: 41826552
The ampersand (&) is the standard Access concatenation character.  The plus (+) can be used but it handles nulls differently so unless you need the special treatment of nulls, it is best to stick with standard.
0
 
LVL 21

Assisted Solution

by:crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access earned 100 total points (awarded by participants)
ID: 41826574
not sure if this works in FoxPro, but here is VBA code to pull DIGITS out of a string:
Function GetDigits(psStringWithNumbers As String) As String
'8-6-08 s4p
   Dim sNumber As String _
      , i As Integer _
      , sChar As String * 1
      
   sNumber = ""
   'loop through and only keep numeric characters
   For i = 1 To Len(psStringWithNumbers)
      sChar = Mid(psStringWithNumbers, i, 1)
      If IsNumeric(sChar) Then
         sNumber = sNumber & sChar
      Else
         'comment if you don't want to stop looking
         If Len(sNumber) > 0 Then
            GetDigits = sNumber
            Exit Function
         End If
      End If
   Next i
   GetDigits = sNumber
End Function

Open in new window

0
 
LVL 42

Accepted Solution

by:
pcelba earned 400 total points (awarded by participants)
ID: 41826808
FoxPro allows much easier solution but you should tell what data type is the Part Number column and what is its true name as the "Part Number" looks like a title.

Let say the table is open in the current workarea already and column names are PartNum  and  OrigInfo so you may just SET FILTER to records of your interests:

Following commands shoul dwork independently on the PartNum data type.

*-- Display all rows where the PartNum is inside the OrigInfo:
SET FILTER TO TRANSFORM(PartNum) $ OrigInfo

*-- Display all rows where the PartNum isn't inside the OrigInfo:
SET FILTER TO NOT TRANSFORM(PartNum) $ OrigInfo

*-- Display all rows where the numeric part of OrigInfo is inside the PartNum:
SET FILTER TO CHRTRAN(OrigInfo, CHRTRAN(Originfo, "0123456789", ""), "") $ TRANSFORM(partNum)

*-- Display all rows where the numeric part of OrigInfo isn't inside the PartNum:
SET FILTER TO NOT CHRTRAN(OrigInfo, CHRTRAN(Originfo, "0123456789", ""), "") $ TRANSFORM(partNum)

*-- Clear the filter
SET FILTER TO

You may display the data by BROWSE command after you set the filter.

The TRANSFORM() function converts possible numeric value in the PartNum into a text, the double CHRTRAN() use will remove all nonnumeric characters from the text. The $ operator tests the string for a substring occurence.

But I am saying again: post right column names and data types to allow us to help better.
0
 
LVL 42

Expert Comment

by:pcelba
ID: 41847240
The only solution or help suitable for FoxPro environment is in the post https:#a41826808. It explains how to define filters on the data in question to display data which follow given filter condition.

Other answers did not reflect FoxPro environment so they cannot work.

appelonia21, if you have additional questions to this subject ask then, if not then please close the question and mark the solution.
0
 
LVL 42

Expert Comment

by:pcelba
ID: 41875976
Unfortunately, just one correct solution suitable for FoxPro was provided. Other solutions do not work correctly in FoxPro or they suppose FoxPro knows VBA etc. Assisted points were assigned for the good Access solution.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
Getting to know the threat landscape in which DDoS has evolved, and making the right choice to get ourselves geared up to defend against  DDoS attacks effectively. Get the necessary preparation works done and focus on Doing the First Things Right.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

623 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