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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

changing RS null values to "" 1

Status
Not open for further replies.

onressy

Programmer
Mar 7, 2006
421
CA
Hi i'm pulling a record set from tables and looping thru to display values.

some values have NULL values. I was wondering it could be done for each object in the rs by using a script, possibly something like:
Code:
Dim thing 
For each thing in objR2 
if isNull(obj2(thing)) then 
objR2(thing) = "" 
end if 

'then start the loop
Do Until objR2.EOF

Thanks!
 
A null concatinated with an empty string yields an empty string... so if you have something that will barf on a null field then just pass it the field & ""

ex: [tt]Left(oRS("Field1") & "", 1)[/tt]
 
I assume that you mean some values within a given row will be null. If so, then you could do something like this:
Code:
Do Until objR2.EOF [COLOR=green]'This is presumably your recordset object[/color]
val1 = if isnull(objR2(val1)) then "" else objR2(val1)
val2 = if isnull(objR2(val2)) then "" else objR2(val2)
...
Loop
That should be enough to give you an idea of where you need to go.

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
Sheco's concatenation will probably be faster and simpler....

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
The concatenation is quick and efficient, and very easy to code. We use it all the time, in both VBS (ASP) programs and VB programs.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Hi saw the posting and thought I'd add my twopenneth - with a problem like this wouldn't it be better to do the work on the database - with something like SQL server you could add:

ISNULL( val1 , ''))

to your select statement and then you do not have to apply the conditional for each line in your RS.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top