Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Microsoft Access 2016 Split Function

Status
Not open for further replies.

MM1963

Vendor
Feb 15, 2018
38
US
I’m trying to use the split function in Access to split a string into substrings that has a ; delimiter. For some reason “Split” is not being recognized by Access as a valid function. I’m getting an error message stating: Undefine Function “Split” in expression. Anyone else seeing this?
 
Are you trying to use Split() in a query? I don't believe it works there so you have to create a "wrapper" function that you can call.

Code:
Public Function MySplit(strText As String, strFind As String, intSection As Integer) As Variant
    On Error Resume Next
    MySplit = Split(strText, strFind)(intSection)
End Function

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
if standard vba functions stop working this can be a broken reference issue, and not necessarily the reference to vba. Take a look at your references and post the image. Look if any reference shows "MISSING:"

 
I was trying to use the Split function in a query. Still having trouble using the sample vba. For example. I have a string in a field labeled [qtysold] with a value of "1;23;34;0;2". I need to add the values between the semicolons. So 1+23+34+0+2 to get the answer 60.
 
You can try a user-defined function like:

Code:
Public Function GetSum(strText As String, strDelim As String) As Double
    Dim arNums
    Dim dblOut As Double
    Dim intN As Integer
    arNums = Split(strText, strDelim)
    For intN = 0 To UBound(arNums)
        dblOut = dblOut + arNums(intN)
    Next
    GetSum = dblOut
End Function

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
I would do it Duane's way, but you could do that in a query without the UDF
Select Eval(Replace([YourField],";","+")) as TheSum,...
 
Thank you for the additional suggestion. That works as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top