I'm sure this can be done, I just can't wrap my mind around doing it.
I want to pass in a sql string to a Function that will open a recordset and return the result of the recordset to the calling function.
I'm trying to do something like this
I want to pass in a sql string to a Function that will open a recordset and return the result of the recordset to the calling function.
I'm trying to do something like this
Code:
Sub Test()
Dim sqlString As String
sqlString = "Select xxx from yyyy where xxx is null;"
GetRecordSetResults sqlString
'I want to get the value of retVal from the function GetRecordSetResults
If retVal >= 1 Then
Debug.Print "Result is greater than or equal to one!"
End If
End Sub
Public Function GetRecordSetResults (querySQL As String)
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset(querySQL)
retVal = rst.Fields(0)
rst.Close
Set rst = Nothing
End Function