C
CES
All,
I was hoping someone would be able to help me with null values on strings and dates being passed into a Module.
I know that I can test on a field for a null value using IIf([Field]<>"",getFullName([Field]),"") however I'm having difficulty figuring out how to match the IIF() in a module.
When I pass in a null field into the module via tmp and it's an empty value in a string data type, it returns #Error and when it's a null value in a date field, it returns 12:00:00 AM.
Any help on this would be greatly appreciated. Thanks in advance. - CES
Public Function getFullName(tmp As String) As String
Dim strToReturn As String
strToReturn = ""
Dim rst As ADODB.Recordset
Dim strSQL As String
strSQL = "SELECT [cID], [cSir], [cFName], [cMName], [cLName] FROM Contacts WHERE ((([cID])=" & tmp & "));"
Set rst = New ADODB.Recordset
With rst
.ActiveConnection = CurrentProject.Connection
.Open Source:=strSQL, CursorType:=adOpenKeyset, Options:=adCmdText
If Not .EOF Then
If .Fields("cSir") <> "" Then
strToReturn = .Fields("cSir"))
End If
End If
End With
rst.Close
Set rst = Nothing
getFullName = strToReturn
End Function
I was hoping someone would be able to help me with null values on strings and dates being passed into a Module.
I know that I can test on a field for a null value using IIf([Field]<>"",getFullName([Field]),"") however I'm having difficulty figuring out how to match the IIF() in a module.
When I pass in a null field into the module via tmp and it's an empty value in a string data type, it returns #Error and when it's a null value in a date field, it returns 12:00:00 AM.
Any help on this would be greatly appreciated. Thanks in advance. - CES
Public Function getFullName(tmp As String) As String
Dim strToReturn As String
strToReturn = ""
Dim rst As ADODB.Recordset
Dim strSQL As String
strSQL = "SELECT [cID], [cSir], [cFName], [cMName], [cLName] FROM Contacts WHERE ((([cID])=" & tmp & "));"
Set rst = New ADODB.Recordset
With rst
.ActiveConnection = CurrentProject.Connection
.Open Source:=strSQL, CursorType:=adOpenKeyset, Options:=adCmdText
If Not .EOF Then
If .Fields("cSir") <> "" Then
strToReturn = .Fields("cSir"))
End If
End If
End With
rst.Close
Set rst = Nothing
getFullName = strToReturn
End Function