recordset woes!

spinkung

Registered User.
Local time
Today, 01:48
Joined
Dec 4, 2006
Messages
267
Hi all,

I'm trying to return some rows into a textbox on my form. Problem is that if it searches for the uniwue id and find that there are no rows to return i get an error saying: No current reccord.

Here's what i've got.....
Code:
rs1.MoveFirst
Me.comments.Value = ""
Do
Me.comments.Value = LTrim(RTrim(rs1("comments").Value)) & vbCrLf & Me.comments.Value
rs1.MoveNext
Loop Until rs1.EOF

Now i'm pretty sure i need to have an if statment at the start that says something like 'if rs.has no record to return then exit sub...else', but i'm not sure of which function i need.

Can someone point me in the right direction please.

Cheers,
Spinkung.
 
Try:


Code:
rs1.MoveFirst
If Not(rs1.EOF and rs1.BOF) Then
   Me.comments.Value = ""
   Do
   Me.comments.Value = LTrim(RTrim(rs1("comments").Value)) & vbCrLf & Me.comments.Value
   rs1.MoveNext
   Loop Until rs1.EOF
End If
 
or


do until rs1.eof
rsr.movenext
loop
 
Look into the psuedocode given below

Do While Not rs.EOF

Do whatever you want

Loop


If the cursor type is static then you can use the rs1.RecordCount

If rs1.RecorCount = 0 then
GoTo TheLabelYouSuggest
Else

Do whatever you want


End If
 
Last edited:

Users who are viewing this thread

Back
Top Bottom