Function to split text in a query

Leo_Polla_Psemata

Registered User.
Local time
Today, 08:40
Joined
Mar 24, 2014
Messages
364
Hi
From this thread,
http://www.access-programmers.co.uk/forums/showthread.php?t=149053
i tried to use this code
Code:
Public Function SplitFile(intField As Integer, strValue As String, strDelimiter As String) As String
Dim varSplit As Variant

varSplit = Split(strValue, strDelimiter, , vbTextCompare)

SplitFile = varSplit(intField)

End Function

But it returns this error
Code.jpg


Could someone enlighten me about it ?
What should I do/ type ?
I want to use this function in a query and split text like this

MyField1:SplitFile(1,[YourUnSplitFieldName],",")
MyField2:SplitFile(2,[YourUnSplitFieldName],",")
MyField3:SplitFile(3,[YourUnSplitFieldName],",")
 
think it should be

Dim varSplit() As Variant
 
Hi
The code is like this
Code:
Public Function SplitFile(intField As Integer, strValue As String, strDelimiter As String) As String
Dim varSplit() As Variant

varSplit = Split(strValue, strDelimiter, , vbTextCompare)

SplitFile = varSplit(intField)

End Function
And the error
Code1.jpg
 
Split is an access function and you have a module called that?
 
re your last post - suggest your read the whole thread you provided, in particular post #15
 
Code:
varSplit = Split(strValue, strDelimiter, , vbTextCompare)
you have one too many commas
 

Users who are viewing this thread

Back
Top Bottom