我有一个辅助函数,它应该连接名为IBM Notes的 Access 表中的Notes First Name、Notes Middle Name和Notes Surname字段。
助手本身工作正常,但是如果我尝试在上述字段之一具有空条目的行上调用它,则不会调用助手。
无论用作参数的字段是否为空,如何修改用于调用帮助程序的 SQL 以确保它返回结果?
这是用于调用助手的 SQL(DB
设置为CurrentDb
) -
DB.Execute "UPDATE [IBM Notes] SET [Notes Full Name] = NotesFullName([Notes First Name], [Notes Middle Name], [Notes Surname])"
这是助手本身 -
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