IamreallyStuck
Technical User
Hello,
I have a module that strips square brackets from any strings which may contain them. It works fine, unless the string passed into the function is empty, in which case the function returns '#Error'. I've tried to rewrite it to stop this from happening, but i'm new to Access and VBA so I can't get the function to handle empty strings.
This is my function at the moment:
Option Explicit
Function SwapStuff(myStr As String) As String
Dim strHolder As String
If Len(myStr) > 0 Then
strHolder = Replace(myStr, "[", ""
SwapStuff = Replace(strHolder, "]", ""
Else: SwapStuff = ""
End If
End Function
I'm sure that it won't take much to fix this - if anyone could help i'd really appreciate it.
Thanks,
Lee.
I have a module that strips square brackets from any strings which may contain them. It works fine, unless the string passed into the function is empty, in which case the function returns '#Error'. I've tried to rewrite it to stop this from happening, but i'm new to Access and VBA so I can't get the function to handle empty strings.
This is my function at the moment:
Option Explicit
Function SwapStuff(myStr As String) As String
Dim strHolder As String
If Len(myStr) > 0 Then
strHolder = Replace(myStr, "[", ""
SwapStuff = Replace(strHolder, "]", ""
Else: SwapStuff = ""
End If
End Function
I'm sure that it won't take much to fix this - if anyone could help i'd really appreciate it.
Thanks,
Lee.