Firstly, apologies because I am very new to VBA!
I have various tables, eg tblOrders, tblDeliveries which contain the field PartNumber. As they come from different sources, sometimes the PartNumber field will have been populated in a different manner, eg with spaces, dashes etc, and without.
What I need to do is run some code to 'fix' the part numbers in these tables (imported from various spreadsheets), so that they are in a common format, with no non alpha numeric characters.
I've 'borrowed' some code which strips other chars from a user inputted text box..but how could I adapt this to go through all the PartNumber records in a particular table?
Hope someone can help! Thanks
The borrowed code is:
Public Function Strip(intext As String) As String
Dim workstring As String
Dim newstring As String
Dim x As Integer
workstring = intext
For x = 1 To Len(intext)
Select Case Mid(workstring, x, 1)
Case " ", "-", "/", "\", "+", "(", "
", "%", ".", ",", "$", "<", ">", Chr$(34)
'Invalid so do not carry forward to new
Case Else
newstring = newstring & Mid(workstring, x, 1)
End Select
Next x
Strip = newstring
I have various tables, eg tblOrders, tblDeliveries which contain the field PartNumber. As they come from different sources, sometimes the PartNumber field will have been populated in a different manner, eg with spaces, dashes etc, and without.
What I need to do is run some code to 'fix' the part numbers in these tables (imported from various spreadsheets), so that they are in a common format, with no non alpha numeric characters.
I've 'borrowed' some code which strips other chars from a user inputted text box..but how could I adapt this to go through all the PartNumber records in a particular table?
Hope someone can help! Thanks
The borrowed code is:
Public Function Strip(intext As String) As String
Dim workstring As String
Dim newstring As String
Dim x As Integer
workstring = intext
For x = 1 To Len(intext)
Select Case Mid(workstring, x, 1)
Case " ", "-", "/", "\", "+", "(", "
'Invalid so do not carry forward to new
Case Else
newstring = newstring & Mid(workstring, x, 1)
End Select
Next x
Strip = newstring