Basic do - loop issue

virtualpete

Registered User.
Local time
Yesterday, 17:11
Joined
Aug 25, 2010
Messages
21
Hi, I have a strange problem and cannot see why my script is not working properly.

Basically the scipt works and outputs the file but it misses paret of the data at the following line

' Write contents section
Do Until rstProp.EOF
WriteMapContents
rstProp.MoveNext
Loop

everything before and after writes to the file.

Here is my code if anyone would be so kind as to see where is might be going wrong:


Sub CreateHNNewMap()

'Declare variables
Dim db As Database ' Database
Dim strHTMLOut As String ' HTML output file name

' Open database and HTML & property recordset
Set db = DBEngine.Workspaces(0).Databases(0)
Set rstHTMLindex = db.OpenRecordset("Select * From tblHNNewSiteMap", dbOpenSnapshot)
Set rstProp = db.OpenRecordset("SELECT * FROM tblRentalProperties WHERE Active = 'Live' ORDER BY [Our ref];", dbOpenSnapshot)
Set rstProp10 = db.OpenRecordset("SELECT * FROM tblRentalProperties WHERE Active = 'Live' ORDER BY [Our ref];", dbOpenSnapshot)

' Open input & output files
strHTMLOut = HTMLDir & "NewMap.htm"
intFileOut = FreeFile() ' Get next file no.
Open strHTMLOut For Output As intFileOut ' Open output file
' Write file header
Temp = rstHTMLindex!html1
Print #intFileOut, Temp ' Write data line




' Write var positions section
Do Until rstProp.EOF
WriteHNNewMap
rstProp.MoveNext
Loop


' Write var positions end
Temp = rstHTMLindex!html2b
Print #intFileOut, Temp ' Write data line



' Write contents section
Do Until rstProp.EOF
WriteMapContents
rstProp.MoveNext
Loop


' Write footer
Temp = rstHTMLindex!html3
Print #intFileOut, Temp ' Write data line



' Tidy up
Close #intFileOut
rstProp.Close
db.Close
Set rstProp = Nothing
Set db = Nothing

End Sub

----------------------------------------------------------
Sub WriteHNNewMap()

Temp = rstHTMLindex!html2 & rstProp![Our Ref] & "," & rstProp![Lat:] & "," & rstProp![Long:] & rstHTMLindex!html2a

Print #intFileOut, Temp

End Sub
--------------------------------------------------------
Sub WriteMapContents()

Temp = rstHTMLindex!html2a & rstProp![Our Ref]

Print #intFileOut, Temp

End Sub


Mnay thanks in anticipation :)
 
This would seem to mean you are at EOF?

Do Until rstProp.EOF

This would be due to you having reached EOF when you Write var positions section
You would need to reset the record pointer before starting the test for EOF for the contents?
 
The previous loop on the same recordset . . .
Code:
[COLOR="Green"]' Write var positions section[/COLOR]
Do Until rstProp.EOF
    WriteHNNewMap
    rstProp.MoveNext
Loop
. . . leaves it at .eof. When code reaches this loop . . .
Code:
Do Until rstProp.EOF
    WriteMapContents
    rstProp.MoveNext
Loop
. . . .eof is already true.
 

Users who are viewing this thread

Back
Top Bottom