Removing the first character of a string if it equals something

There is nothing particularly wrong with your code, the "ambiguous" error message in this context is very likely to be because you have another sub or function in a different module with the same name. Search to find the duplicate name.

If you put the function in the module belonging to a form or report, it is probably best to skip "Public". If you intend the function to be used by several forms, create a new module that is not attached to a form and put the functions that are intended for all forms and reports in that.

It is nearly always good to provide the full error message and error number.


I have tested your function in Access 2010 and it worked just fune.. You can also use this code:

Public Function RemoveFirstChar(RemFstChar As String) As String
Dim TempString As String
TempString = RemFstChar
If Left(RemFstChar, 1) = "1" Then
    If Len(RemFstChar) > 1 Then
        TempString = Right(RemFstChar, Len(RemFstChar) - 1)
    End If
End If
RemoveFirstChar = TempString
End Function

Tags:

Ms Access

Vba