Looping IN recordset and Displaying Resulst

bbrendan

Registered User.
Local time
Today, 02:38
Joined
Oct 31, 2001
Messages
35
Hi All,

Im sort of new to VBA but need some help.

What I would like to do is loop through a table and grab the results and populate them into my text string like

Available in the Following Colours:

White
Mist Grey
Ivory
Peach

In my code, I link to a colour table and grab the colour and link this with my product description table and then wrap it in html tags. Then I save this using the open file.
Then I can view this html file in a broswer window on my form the check the html code.

**** but when I do the loop it goes straight to the last one!, and misses out the first 3 colurs.

Can anyone point me in the right direct PLEASE!!!!!

-----------------------------------
Dim strColour As string
Dim mydb2 As ADODB.Recordset
Dim intFile As Integer

Set mydb2 = New ADODB.Recordset
intFile = FreeFile

mydb2.ActiveConnection = CurrentProject.Connection
mydb2.Open "select Colour_Text from Colours where proddesc_id =" & Me.PRODDESCID

While Not mydb2.EOF
strColour = mydb2.Fields("colour_text")

Me.html_text = "<font face='Verdana' size='2'><b>" & Me.SHORTTEXT & "</b></font>" _
& "<font face='Verdana' size='2'>" & "<p>" _
& "<b>Features</b><hr>" _
& "<b>::</b> " & strFeatures & "</b>" _
& "<p>" & Me.PRODDESCR _
& "<p><i>Available in the Following Colours:</i><p>" _
& "<b>::</b> " & strColour _ '*** See here I need this to show all colours!!!
& "</font>"

Open "E:\SBT\Supplier_Information\Website Connection\html\test.html" For Output As intFile

Print #intFile, _
Me.html_text
Close intFile

mydb2.MoveNext
Wend
mydb2.Close

Set mydb2 = Nothing

Me.WebBrowser1.Navigate "E:\SBT\Supplier_Information\Website Connection\html\test.html"
-------

thanks
brendan
 
Brendan,

I think this is the problem:
you open a file,
you write one record to the file,
you close the file,
you get the next records from a recordset and repeat the actions above.

When you close and reopen the file, the next write replaces the previous content. So leave the file open until you have finished with the recordset.

RichM
 

Users who are viewing this thread

Back
Top Bottom