BOF Problem

bbrendan

Registered User.
Local time
Today, 07:21
Joined
Oct 31, 2001
Messages
35
Hi,

I have this code below where it queries a table. What currently happens is If BOF then stop. But I need it to say Ok not records in this table let continue on to next statement.

like ....

If mydb.BOF = true then Exit Sub 'This just stops the routine.

What I would like to do is

If mydb.BOF = true then goto next routine 'Which is the colours see code below.


Code
--------------------
' this one is for Features
mydb.ActiveConnection = CurrentProject.Connection
mydb.Open "select Feature_Text from Features where proddesc_id =" & Me.PRODDESCID
If mydb.BOF = True Then Exit Sub ' **** Here I dont want it to exit sub but goto the next part below Colours
With mydb
If .RecordCount Then
.MoveFirst
Do Until mydb.EOF
strFeatures = strFeatures & "<b><br>::</b> " & mydb.Fields("Feature_Text")
mydb.MoveNext
Loop

' this one is for Colours
mydb2.ActiveConnection = CurrentProject.Connection
mydb2.Open "select Colour_Text from Colours where proddesc_id =" & Me.PRODDESCID
If mydb2.BOF = True Then Exit Sub
With mydb2
If .RecordCount Then
.MoveFirst
Do Until mydb2.EOF
strColour = strColour & "<br><b>:: </b>" & mydb2.Fields("colour_text")
mydb2.MoveNext
Loop


Appreciate any help
thanks
 
The easiest thing would be to use your if statement to run code only when mydb.BOF = False

Code:
If mydb.BOF = False Then 
     With mydb 
     If .RecordCount Then 'I wasn't sure what this If was for or where the End If was located
          .MoveFirst 
          Do Until mydb.EOF 
                strFeatures = strFeatures & "<b><br>::</b> " & mydb.Fields("Feature_Text") 
                mydb.MoveNext 
          Loop 
End If
 
Hi,

Thanks for your help. Will try this later

cheers
brendan
 

Users who are viewing this thread

Back
Top Bottom