Re: Recordset Data Type
- From: "Ralph" <nt_consulting64@xxxxxxxxx>
- Date: Tue, 5 Dec 2006 14:04:37 -0600
"bz" <nospam@xxxxxxxxx> wrote in message
news:O9gocXKGHHA.3616@xxxxxxxxxxxxxxxxxxxxxxx
Thanks for the input.
If I want to have a function to check for a database null from the
recordset, how do I pass the recordset value to the function?
I want to replace this code with a function:
If Not Isnull(My_Recordset("interest_rate")) Then
Interest_Rate = My_Recordset("interest_rate")
End If
To:
Interest_Rate = Get_Value(My_Recordset("interest_rate"))
There is no overload in VB6.
So, Get_Value must take and return a variant.
And, the code above will not work if the function return a string.
I need to change it to:
Interest_Rate = Cdbl(Get_Value(My_Recordset("interest_rate")))
Am I Correct? or it is not how it is done.
Handling nulls is a pia. Not sure there is a single ideal OSFA, but
attempting to pass a null to a function is definitely not a good idea. There
are various methods depending on what you expect to receive or what you
would like to happen if the field is null. (ie, the default)
[Just to shorten code I am using rs!Rate as shorthand for
My_Recordset("Interest_Rate").Value which will likely stir up another round
of opinions. <g>]
val = IIf (IsNull(rs!Rate), 0#, rs!Rate)
val = IIf(IsNull(rs!Name), "", rs!Name)
val = rs!Rate & ""
val = rs!Name & vbNullString
val = (rs!Rate + 0#)
and so on...
-ralph
.
- Follow-Ups:
- Re: Recordset Data Type
- From: bz
- Re: Recordset Data Type
- References:
- Recordset Data Type
- From: bz
- Re: Recordset Data Type
- From: Ralph
- Re: Recordset Data Type
- From: bz
- Recordset Data Type
- Prev by Date: Re: Recordset Data Type
- Next by Date: Re: Recordset Data Type
- Previous by thread: Re: Recordset Data Type
- Next by thread: Re: Recordset Data Type
- Index(es):
Relevant Pages
|
Loading