...

View Full Version : No data entries than fail?



reubenb
02-03-2005, 07:08 AM
hi,

when you are using a SQL statement and getting records from a database,
you use 'If NOT objRS.EOF Then'
and because it is an 'if ... then' statement, you put an 'else' there and give it something to do if there are no records.

how do you do this when there isn't an 'if... then' statement like
'Do While Not objRS.EOF'

?

Thanks.

tboss132
02-03-2005, 09:20 AM
Check this links
If then, else (http://www.w3schools.com/vbscript/vbscript_conditionals.asp)
Do While, loop (http://www.w3schools.com/vbscript/vbscript_looping.asp)

ghell
02-03-2005, 10:51 AM
you could do something like an integer that increases when the loop is run, if after the "loop" line its still 0, there were no records, however i would just do


If NOT objRs.EOF Then
Do While NOT objRs.EOF
'...
objRs.MoveNext
Loop
Else
'there were no records
End Ifalso, you dont NEED an else, and it will work without the if statement at all, this is only for if you want to get any records.. you could also check for BOF to see if the recordset exists i spose *shrugs* ive never used BOF, i dont really know what its there for :p

reubenb
02-03-2005, 11:23 AM
That works great - thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum