G
gibsonsgman
alright i have an issue with the split function. I need tosearch
through an imported table and cut out some unneeded text from the
field. the field is in a really weird format so i am having a bit of
trouble doing this. ill post my code and an example of the field im
trying to trim. i need all the help i can get.
Field:
STOCK DESCRIPTION:
PACKING, ITEM#32 ON DRAWING 20535-H, FOR
-
USE ON 20", 300# AIR OPERATOR TESTABLE
CHECK VALVE, ATW REFERENCE (10864)
67/6/1033.
ATW PART NO. 25781 054 0000 000
-
INTERNAL NOTES:
SEE TG-ATOA & TG-XSAN/NSP DWG. NO.
NX-86
Code:
Private Sub cmdEdit_Click()
Dim rs As Recordset
Dim stTemp As String
Dim stSplitTemp() As String
Dim stDesc As String
Dim len1 As Long
Dim len2 As Long
Dim stT As String
Set rs = CurrentDb.OpenRecordset("Sheet3")
rs.MoveFirst
Do While Not rs.EOF
If Not IsNull(rs.Fields("Com Name").Value) Then
stTemp = rs.Fields("Com Name").Value
stT = vbNewLine & "-" & vbNewLine
stSplitTemp = Split(stTemp, stT, -1, vbDatabaseCompare)
len1 = Len(stSplitTemp(1))
len2 = InStr(1, stSplitTemp(1), " STOCK DESCRIPTION:",
vbTextCompare)
stDesc = Right(stSplitTemp(1), len1 - len2)
MsgBox Trim(stDesc)
End If
rs.MoveNext
Loop
End Sub
alright there it is. it could be complete wrong but i think the issue
is in the split statement, it doesn't seem to like my vbnew line
format.
through an imported table and cut out some unneeded text from the
field. the field is in a really weird format so i am having a bit of
trouble doing this. ill post my code and an example of the field im
trying to trim. i need all the help i can get.
Field:
STOCK DESCRIPTION:
PACKING, ITEM#32 ON DRAWING 20535-H, FOR
-
USE ON 20", 300# AIR OPERATOR TESTABLE
CHECK VALVE, ATW REFERENCE (10864)
67/6/1033.
ATW PART NO. 25781 054 0000 000
-
INTERNAL NOTES:
SEE TG-ATOA & TG-XSAN/NSP DWG. NO.
NX-86
Code:
Private Sub cmdEdit_Click()
Dim rs As Recordset
Dim stTemp As String
Dim stSplitTemp() As String
Dim stDesc As String
Dim len1 As Long
Dim len2 As Long
Dim stT As String
Set rs = CurrentDb.OpenRecordset("Sheet3")
rs.MoveFirst
Do While Not rs.EOF
If Not IsNull(rs.Fields("Com Name").Value) Then
stTemp = rs.Fields("Com Name").Value
stT = vbNewLine & "-" & vbNewLine
stSplitTemp = Split(stTemp, stT, -1, vbDatabaseCompare)
len1 = Len(stSplitTemp(1))
len2 = InStr(1, stSplitTemp(1), " STOCK DESCRIPTION:",
vbTextCompare)
stDesc = Right(stSplitTemp(1), len1 - len2)
MsgBox Trim(stDesc)
End If
rs.MoveNext
Loop
End Sub
alright there it is. it could be complete wrong but i think the issue
is in the split statement, it doesn't seem to like my vbnew line
format.