Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with If and Then

Status
Not open for further replies.
Apr 11, 2003
105
US
can someone give me a hand with the verbage of the the code? I want to pull information from a database to display in a form, if it is blank it will write a space to fill the form. when i save it it is then saving that space, and not creating a table anymore. because the cell is not null. So my question is how do i write a statement that would look at a access table, if the cell is null write a space, if the cell has information in it, then write the information.

I put this togeather and it worked for the null value, i just need to take it to the next level.
Code:
<% If isNull(rstDBEdit.Fields("asset_tag")) then
%><P>&nbsp;</P><%					
else
response.write rstDBEdit.Fields("asset_tag").Value
end if%>

This is what i tried to write but i know There is something worng with it..

Code:
<% If isNull(rstDBEdit.Fields("asset_tag")) then
%><P>&nbsp;</P><%					
else
%><P>&nbsp;</P><%(rstDBEdit.Fields("asset_tag")) then
%><P>&nbsp;</P><%
else
response.write rstDBEdit.Fields("asset_tag").Value
end if%>
 
Hi,

IsNull is a very special condition and NOT the absence of data in a field.
The Null value indicates that the Variant contains no valid data. Null is not the same as Empty, which indicates that a variable has not yet been initialized. It is also not the same as a zero-length string (""), which is sometimes referred to as a null string.
Code:
<% If (rstDBEdit.Fields("asset_tag") = "") then
%><P>&nbsp;</P><%                    
else
response.write rstDBEdit.Fields("asset_tag").Value
end if%>
:)

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at faq222-2244
 
yup,
also take a look at isEmpty() function...

Known is handfull, Unknown is worldfull
 
vbkris,

IsEmpty tests a Variant if it's been initialized.

Skip,

Be advised: Alcohol and Calculus do not mix!
If you drink, don't derive!

Want to get great answers to your Tek-Tips questions? Have a look at faq222-2244
 
Skip,
I've a question now. Are you saying that using "" will catch the null values or are you saying to use the "" in addition to the isnull test?
 
It depends what you need to test for.

Skip,

[glasses] [red]Be advised:[/red] Alcohol and Calculus do not mix!
If you drink, don't derive! [tongue]

Want to get great answers to your Tek-Tips questions? Have a look at FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top