Home All Groups Group Topic Archive Search About

Extract string from field in 1 table

Author
13 Feb 2007 1:40 AM
staspe
vb.net 2003
Access 2003

The following code is using a Criteria Table
"tblVendNameFindReplace"
with 2 fields  txtFind   txtReplace

and a data table  "tblData"  Using   "fldDescription"


What I'am trying to do:
Find the   Value  "txtFind" inside  the  fldDescription string and use
the txtReplace value and place it in   fldMfgname


Problem:
However the code will only Update the fldMfgname field if the string
matches exactly



tblData:  before routine runs example
fldDescription
fld Mfgname
PUSH , BAR , 102K06301 , LAWSON, 62A28477
SANDPAPER , 120GRIT , 2 50YDS , MSC ,73167
VACCUM , CU , P70208, LAWSON
VACCUM , CU , P70608, FASTENAL

after routines runs....
fldDescription
fld Mfgname
PUSH , BAR , 102K06301 , LAWSON, 62A28477        LAWSON
SANDPAPER , 120GRIT , 2 50YDS , MSC ,73167       MSC
VACCUM , CU , P70208, LAWSON                           LAWSON
VACCUM , CU , P70608, FASTENAL                         FASTENAL



Dim conn As System.Data.OleDb.OleDbConnection
        Dim tblVendNameFindReplace As New DataTable
        Dim tblData As New DataTable

        conn = New
System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.
4.0;Data Source=C:\DM2007\SkuCat.mdb")
        'make dataadapters
        Dim dac As New System.Data.OleDb.OleDbDataAdapter("SELECT
fldId, txtFind, txtReplace FROM tblVendNameFindReplace", conn)
        Dim dad As New System.Data.OleDb.OleDbDataAdapter("SELECT
fldDid, fldMfgname, fldMfrnum, fldDescription FROM tblData", conn)
        Dim cb As New System.Data.OleDb.OleDbCommandBuilder(dad)
        'get the datables from Access
        dac.Fill(tblVendNameFindReplace)
        dad.Fill(tblData)
        'revise the data
        ' for a name find dump
        For Each drc As DataRow In tblVendNameFindReplace.Rows
            For Each drd As DataRow In tblData.Rows
' just so I can see the values   =======
    Dim strDesc As String
                  Dim strFind As String
                   strDesc = drd("fldDescription")
                       strFind = drc("txtFind")
' just so I can see the values   =======
If drd("fldDescription") Like drc("txtFind") Then
                    drd("fldMfgname") = drc("txtReplace")
                End If

            Next
        Next
        'send updated table back to Access
        dad.Update(tblData)
        MsgBox("DONE Vendor Name Dump ", MsgBoxStyle.Information)

Thanks
fordraiders

Author
13 Feb 2007 9:10 AM
Garik
Hi fordraiders,

Try:

If strDesc Like "*" & strFind & "*" Then
    'Override your field

End If

--
Regards,
Garik Melkonyan
MCP, MCAD, MCSD .NET


Show quote
"sta***@insightbb.com" wrote:

> vb.net 2003
> Access 2003
>
> The following code is using a Criteria Table
> "tblVendNameFindReplace"
>  with 2 fields  txtFind   txtReplace
>
> and a data table  "tblData"  Using   "fldDescription"
>
>
> What I'am trying to do:
> Find the   Value  "txtFind" inside  the  fldDescription string and use
> the txtReplace value and place it in   fldMfgname
>
>
> Problem:
> However the code will only Update the fldMfgname field if the string
> matches exactly
>
>
>
> tblData:  before routine runs example
> fldDescription
> fld Mfgname
> PUSH , BAR , 102K06301 , LAWSON, 62A28477
> SANDPAPER , 120GRIT , 2 50YDS , MSC ,73167
> VACCUM , CU , P70208, LAWSON
> VACCUM , CU , P70608, FASTENAL
>
> after routines runs....
> fldDescription
> fld Mfgname
> PUSH , BAR , 102K06301 , LAWSON, 62A28477        LAWSON
> SANDPAPER , 120GRIT , 2 50YDS , MSC ,73167       MSC
> VACCUM , CU , P70208, LAWSON                           LAWSON
> VACCUM , CU , P70608, FASTENAL                         FASTENAL
>
>
>
> Dim conn As System.Data.OleDb.OleDbConnection
>         Dim tblVendNameFindReplace As New DataTable
>         Dim tblData As New DataTable
>
>         conn = New
> System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.
> 4.0;Data Source=C:\DM2007\SkuCat.mdb")
>         'make dataadapters
>         Dim dac As New System.Data.OleDb.OleDbDataAdapter("SELECT
> fldId, txtFind, txtReplace FROM tblVendNameFindReplace", conn)
>         Dim dad As New System.Data.OleDb.OleDbDataAdapter("SELECT
> fldDid, fldMfgname, fldMfrnum, fldDescription FROM tblData", conn)
>         Dim cb As New System.Data.OleDb.OleDbCommandBuilder(dad)
>         'get the datables from Access
>         dac.Fill(tblVendNameFindReplace)
>         dad.Fill(tblData)
>         'revise the data
>         ' for a name find dump
>         For Each drc As DataRow In tblVendNameFindReplace.Rows
>             For Each drd As DataRow In tblData.Rows
> ' just so I can see the values   =======
>     Dim strDesc As String
>                   Dim strFind As String
>                    strDesc = drd("fldDescription")
>                        strFind = drc("txtFind")
>  ' just so I can see the values   =======
> If drd("fldDescription") Like drc("txtFind") Then
>                     drd("fldMfgname") = drc("txtReplace")
>                 End If
>
>             Next
>         Next
>         'send updated table back to Access
>         dad.Update(tblData)
>         MsgBox("DONE Vendor Name Dump ", MsgBoxStyle.Information)
>
> Thanks
> fordraiders
>
>
Author
13 Feb 2007 8:51 PM
staspe
On Feb 13, 3:10 am, Garik <garik_ma@do not spam.yahoo.com> wrote:
Show quote
> Hi fordraiders,
>
> Try:
>
> If strDesc Like "*" & strFind & "*" Then
>     'Override your field
>
> End If
>
> --
> Regards,
> Garik Melkonyan
> MCP, MCAD, MCSD .NET
>
>
>
> "sta***@insightbb.com" wrote:
> > vb.net 2003
> > Access 2003
>
> > The following code is using a Criteria Table
> > "tblVendNameFindReplace"
> >  with 2 fields  txtFind   txtReplace
>
> > and a data table  "tblData"  Using   "fldDescription"
>
> > What I'am trying to do:
> > Find the   Value  "txtFind" inside  the  fldDescription string and use
> > the txtReplace value and place it in   fldMfgname
>
> > Problem:
> > However the code will only Update the fldMfgname field if the string
> > matches exactly
>
> > tblData:  before routine runs example
> > fldDescription
> > fld Mfgname
> > PUSH , BAR , 102K06301 , LAWSON, 62A28477
> > SANDPAPER , 120GRIT , 2 50YDS , MSC ,73167
> > VACCUM , CU , P70208, LAWSON
> > VACCUM , CU , P70608, FASTENAL
>
> > after routines runs....
> > fldDescription
> > fld Mfgname
> > PUSH , BAR , 102K06301 , LAWSON, 62A28477        LAWSON
> > SANDPAPER , 120GRIT , 2 50YDS , MSC ,73167       MSC
> > VACCUM , CU , P70208, LAWSON                           LAWSON
> > VACCUM , CU , P70608, FASTENAL                         FASTENAL
>
> > Dim conn As System.Data.OleDb.OleDbConnection
> >         Dim tblVendNameFindReplace As New DataTable
> >         Dim tblData As New DataTable
>
> >         conn = New
> > System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.
> > 4.0;Data Source=C:\DM2007\SkuCat.mdb")
> >         'make dataadapters
> >         Dim dac As New System.Data.OleDb.OleDbDataAdapter("SELECT
> > fldId, txtFind, txtReplace FROM tblVendNameFindReplace", conn)
> >         Dim dad As New System.Data.OleDb.OleDbDataAdapter("SELECT
> > fldDid, fldMfgname, fldMfrnum, fldDescription FROM tblData", conn)
> >         Dim cb As New System.Data.OleDb.OleDbCommandBuilder(dad)
> >         'get the datables from Access
> >         dac.Fill(tblVendNameFindReplace)
> >         dad.Fill(tblData)
> >         'revise the data
> >         ' for a name find dump
> >         For Each drc As DataRow In tblVendNameFindReplace.Rows
> >             For Each drd As DataRow In tblData.Rows
> > ' just so I can see the values   =======
> >     Dim strDesc As String
> >                   Dim strFind As String
> >                    strDesc = drd("fldDescription")
> >                        strFind = drc("txtFind")
> >  ' just so I can see the values   =======
> > If drd("fldDescription") Like drc("txtFind") Then
> >                     drd("fldMfgname") = drc("txtReplace")
> >                 End If
>
> >             Next
> >         Next
> >         'send updated table back to Access
> >         dad.Update(tblData)
> >         MsgBox("DONE Vendor Name Dump ", MsgBoxStyle.Information)
>
> > Thanks
> > fordraiders- Hide quoted text -
>
> - Show quoted text -

Well  that  seemed simple enough....
Thanks Very Much!
Author
13 Feb 2007 8:52 PM
staspe
On Feb 13, 3:10 am, Garik <garik_ma@do not spam.yahoo.com> wrote:
Show quote
> Hi fordraiders,
>
> Try:
>
> If strDesc Like "*" & strFind & "*" Then
>     'Override your field
>
> End If
>
> --
> Regards,
> Garik Melkonyan
> MCP, MCAD, MCSD .NET
>
>
>
> "sta***@insightbb.com" wrote:
> > vb.net 2003
> > Access 2003
>
> > The following code is using a Criteria Table
> > "tblVendNameFindReplace"
> >  with 2 fields  txtFind   txtReplace
>
> > and a data table  "tblData"  Using   "fldDescription"
>
> > What I'am trying to do:
> > Find the   Value  "txtFind" inside  the  fldDescription string and use
> > the txtReplace value and place it in   fldMfgname
>
> > Problem:
> > However the code will only Update the fldMfgname field if the string
> > matches exactly
>
> > tblData:  before routine runs example
> > fldDescription
> > fld Mfgname
> > PUSH , BAR , 102K06301 , LAWSON, 62A28477
> > SANDPAPER , 120GRIT , 2 50YDS , MSC ,73167
> > VACCUM , CU , P70208, LAWSON
> > VACCUM , CU , P70608, FASTENAL
>
> > after routines runs....
> > fldDescription
> > fld Mfgname
> > PUSH , BAR , 102K06301 , LAWSON, 62A28477        LAWSON
> > SANDPAPER , 120GRIT , 2 50YDS , MSC ,73167       MSC
> > VACCUM , CU , P70208, LAWSON                           LAWSON
> > VACCUM , CU , P70608, FASTENAL                         FASTENAL
>
> > Dim conn As System.Data.OleDb.OleDbConnection
> >         Dim tblVendNameFindReplace As New DataTable
> >         Dim tblData As New DataTable
>
> >         conn = New
> > System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.
> > 4.0;Data Source=C:\DM2007\SkuCat.mdb")
> >         'make dataadapters
> >         Dim dac As New System.Data.OleDb.OleDbDataAdapter("SELECT
> > fldId, txtFind, txtReplace FROM tblVendNameFindReplace", conn)
> >         Dim dad As New System.Data.OleDb.OleDbDataAdapter("SELECT
> > fldDid, fldMfgname, fldMfrnum, fldDescription FROM tblData", conn)
> >         Dim cb As New System.Data.OleDb.OleDbCommandBuilder(dad)
> >         'get the datables from Access
> >         dac.Fill(tblVendNameFindReplace)
> >         dad.Fill(tblData)
> >         'revise the data
> >         ' for a name find dump
> >         For Each drc As DataRow In tblVendNameFindReplace.Rows
> >             For Each drd As DataRow In tblData.Rows
> > ' just so I can see the values   =======
> >     Dim strDesc As String
> >                   Dim strFind As String
> >                    strDesc = drd("fldDescription")
> >                        strFind = drc("txtFind")
> >  ' just so I can see the values   =======
> > If drd("fldDescription") Like drc("txtFind") Then
> >                     drd("fldMfgname") = drc("txtReplace")
> >                 End If
>
> >             Next
> >         Next
> >         'send updated table back to Access
> >         dad.Update(tblData)
> >         MsgBox("DONE Vendor Name Dump ", MsgBoxStyle.Information)
>
> > Thanks
> > fordraiders- Hide quoted text -
>
> - Show quoted text -

Beautiful   Thanks !

AddThis Social Bookmark Button