![]() |
MS Access COALESCE Function Gives you the functionality of the SQL Server COALESCE function in MS Access |
Public Function fnCOALESCE(MyQuery As String) As String Dim db As DAO.Database Dim rs As DAO.Recordset Dim sOutputString As String Set db = CurrentDb() Set rs = db.OpenRecordset(MyQuery) fnCOALESCE = "" sOutputString = "" If rs.BOF And rs.EOF Then Exit Function ' No records to process Else rs.MoveFirst Do Until rs.EOF sOutputString = sOutputString & rs.Fields(0) DoEvents rs.MoveNext Loop End If fnCOALESCE = sOutputString Set rs = Nothing Set db = Nothing End Function |