Dear Experts,
I am trying to use the Split() function to parse a long string of data separated by the * symbol in a field. Here is an example of what this string looks like -
I think I have put together the function correctly (see code at bottom of post) because it works when I test it in the immediate window in vba.
Using the above example I get the result I want...
Beautiful and exactly what I want, but when I try my function in a query, I get the #Error message in the query field.
This is what it looks like in the query grid, which results in #Error:
The [CAPRVSOURCE] is defined as a Text field in the table.
Can anyone help me out? Thank you in advance!
I am trying to use the Split() function to parse a long string of data separated by the * symbol in a field. Here is an example of what this string looks like -
Code:
00A398390*330861255*RIVERSIDE REGIONAL PEDIATRIC M
Using the above example I get the result I want...
Code:
SplitJEDI_NPI("00A398390*330861255*RIVERSIDE REGIONAL PEDIATRIC M")
Returns this: 330861255
This is what it looks like in the query grid, which results in #Error:
Code:
Expr1: SplitJEDI_NPI([CAPRVSOURCE])
Can anyone help me out? Thank you in advance!
Code:
Public Function SplitJEDI_NPI(ByVal InputString As Variant)
Dim strInput As String
'Declare an array that will hold data elements
Dim strArrayNPI() As String
Dim strResult As String
strInput = InputString
'Debug.Print strInput
Erase strArrayNPI
'Split input string and store as an array
strArrayNPI = Split(strInput, "*")
'Trim the results
strResult = Trim(strArrayNPI(0))
Debug.Print strResult
SplitJEDI_NPI = strResult
End Function
Comment