| | |
|
|
|
Parsing Data |
| message from =?Utf-8?B?VG9ueQ==?= on 26 May 2004 |
Good Afternoon!
Order Number :5202518 Delivery No : 483385 Line No : 22
I need to parse 5202518 into one field, 483385 into a second field and 22 into another. Can anyone assist in this matter?
Regards,
Tony
|
| Albert D. Kallal replied to =?Utf-8?B?VG9ueQ==?= on 26 May 2004 |
Public Sub test1()
Dim v As Variant
Dim strTest As String
Dim OrderNum As String
Dim DeliveryNum As String
Dim LineNum As String
strTest = "Order Number :5202518 Delivery No : 483385 Line No : 22"
v = Split(strTest, ":")
OrderNum = Split(v(1), " ")(0)
DeliveryNum = Split(v(2), " ")(1)
LineNum = Trim(v(3))
Debug.Print "ordernum = " & OrderNum
Debug.Print "Delivery Num = " & DeliveryNum
Debug.Print "line num = " & LineNum
End Sub
The only real problem you will encounter is if there is a "space" before the
:, or not. You will thus have to adjust the above code based on this issue.
Try pasting the above code into a module...and run it....
You can then use the above for the basis of a processing loop (only another
few lines of extra code).
|
| =?Utf-8?B?VG9ueQ==?= replied to Albert D. Kallal on 26 May 2004 |
Thanks Albert! Unfortunatley, I forgot to mention that I was trying to parse this data within a query. Doh! Sorry.... Do you know how to parse with a query?
|
| Albert D. Kallal replied to =?Utf-8?B?VG9ueQ==?= on 27 May 2004 |
Public Funciton gOrderNum(vString as varient) as varient
dim vTemp as varient
if isnull(vString) = true then
exit funciton
end if
vTemp = split(vString),":")(1)
gOrderNum = split(vTemp(1)," ")(0)
end fucntion
You can then use the above expression gOrderNum([fieldToParse]) in the
query.....
So, you will need to write 3 functions. Just place them in a standard
module..and then you can use them in the query...
|
|
Archived message: Parsing Data (Microsoft Access Error Message)