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

x
?
Solved

Foxpro - Searching for numbers in separate column

Posted on 2016-10-03
8
Medium Priority
?
56 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
Technology Partners: 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!

 
LVL 39

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 22

Assisted Solution

by:crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access earned 400 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 43

Accepted Solution

by:
pcelba earned 1600 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 43

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 43

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

Implementing Azure Infrastructure Exam 70-533

This course is designed to familiarize and instruct students in the content that is covered by Microsoft Exam 70-533, Implementing Microsoft Azure Solutions. It focuses on all the November 2016 objective domain topics.

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…
Experts give $3,000 toward hurricane relief efforts—but that's not all!
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

670 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