I have a helper function that should concatenate the Notes First Name, Notes Middle Name and Notes Surname fields from an Access table named IBM Notes.
The helper itself works fine, however if I attempt to call it on a row that has an empty entry for one of the aforementioned fields, the helper is not called.
How can I amend the SQL that is used to call the helper to ensure that it returns a result regardless of whether or not a field used as a parameter is empty?
Here is the SQL used to call the helper (DB
is set to CurrentDb
) -
DB.Execute "UPDATE [IBM Notes] SET [Notes Full Name] = NotesFullName([Notes First Name], [Notes Middle Name], [Notes Surname])"
And here is the helper itself -
Function NotesFullName(Optional ByVal firstName As String = "", _
Optional ByVal middleName As String = "", _
Optional ByVal surname As String = "") As String
NotesFullName = Trim( _
IIf(Not firstName = "", firstName & " ", "") & _
IIf(Not middleName = "", middleName & " ", "") & _
IIf(Not surname = "", surname, "") _
)
End Function