I need to convert a column of serial numbers so I can link two tables.
In one table they are stored as follows:
005-666 or D0001 or L1234 these can all vary in length
In the table I want to like to they are stored as follows
005-666@ Blah Blah
D0001-01-03
D0001/06/02
Machine (no.1) D0001-02
L1234 Bugger
And a number of other different formats. I've done some simple filtering as follows:
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT rDawMachineLocal.* FROM rDawMachineLocal")
With rst
.MoveFirst
Do Until .EOF
dawserial = Trim(![ceq_serial])
If Not dawserial = "" Then
LeftTrimPosition = InStr(1, ![ceq_serial], "/")
Select Case LeftTrimPosition
Case Is > 7
LeftTrimPosition = InStr(1, ![ceq_serial], " ")
Case 0
LeftTrimPosition = InStr(1, ![ceq_serial], " ")
End Select
.Edit
If LeftTrimPosition = 0 Then
![Serial] = dawserial
Else
![Serial] = Left(dawserial, LeftTrimPosition - 1)
End If
.Update
.MoveNext
LeftTrimPosition = 0
Else
.Edit
![Serial] = "Not Available"
.Update
.MoveNext
LeftTrimPosition = 0
End If
Loop
End With
dbs.Close
But this only captures the simple variations, does anybody have any tips or examples of how I can filter the D****** or the 005-*** perfectly? Thanks in advance. R
In one table they are stored as follows:
005-666 or D0001 or L1234 these can all vary in length
In the table I want to like to they are stored as follows
005-666@ Blah Blah
D0001-01-03
D0001/06/02
Machine (no.1) D0001-02
L1234 Bugger
And a number of other different formats. I've done some simple filtering as follows:
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT rDawMachineLocal.* FROM rDawMachineLocal")
With rst
.MoveFirst
Do Until .EOF
dawserial = Trim(![ceq_serial])
If Not dawserial = "" Then
LeftTrimPosition = InStr(1, ![ceq_serial], "/")
Select Case LeftTrimPosition
Case Is > 7
LeftTrimPosition = InStr(1, ![ceq_serial], " ")
Case 0
LeftTrimPosition = InStr(1, ![ceq_serial], " ")
End Select
.Edit
If LeftTrimPosition = 0 Then
![Serial] = dawserial
Else
![Serial] = Left(dawserial, LeftTrimPosition - 1)
End If
.Update
.MoveNext
LeftTrimPosition = 0
Else
.Edit
![Serial] = "Not Available"
.Update
.MoveNext
LeftTrimPosition = 0
End If
Loop
End With
dbs.Close
But this only captures the simple variations, does anybody have any tips or examples of how I can filter the D****** or the 005-*** perfectly? Thanks in advance. R