there is no EOF in my code

adaniele

Registered User.
Local time
Today, 09:16
Joined
Jul 18, 2005
Messages
176
hi guys.....something is wrong in my logic or code. and i dont know why.

What im trying to do is: select a code from a combo in a form. Then go to a table permitdetails and see how many records i have for that code and send those records to a word doc. The thing is that i cant send more than 5 record per doc, so i am counting them.

i currently have 5 records in permitdetails.
the problem is once it finishes to read permitdetails table it does nothing else. Does not enter in the conditionals. it dies.


Code:
            ' insert values per record
            Set rstmerge2 = dbsname.OpenRecordset("permitdetails", dbOpenTable)
            rstmerge2.MoveFirst
            rcount = 0
            vpage = 1
            Do While (Not rstmerge2.EOF) Or (rcount <> vcountp)
                i = 1
                Do While (i <= 5) And (rcount < vcountp)
                    If rstmerge2![issuenumber] = Me.pissuenumber Then
                        'MsgBox i & rcount & vcountp
                        vcontent2 = DLookup("content", "pop", "ifsnumber=" & rstmerge2![ifsnumber] & "")
                        vcan2 = DLookup("can", "pop", "ifsnumber=" & rstmerge2![ifsnumber] & "")
                        vltrs2 = (rstmerge2![qcartons]) * (rstmerge2![qpercarton]) * (vcontent2)
                        DoCmd.RunSQL ("update temppermit set content" & i & "=" & vcontent2 & "")
                        DoCmd.RunSQL ("update temppermit set can" & i & "='" & vcan2 & "'")
                        DoCmd.RunSQL ("update temppermit set tlts" & i & "=" & vltrs2 & "")
                        DoCmd.RunSQL ("update temppermit set qcartons" & i & "=" & rstmerge2![qcartons] & "")
                        DoCmd.RunSQL ("update temppermit set qpercarton" & i & "=" & rstmerge2![qpercarton] & "")
                        DoCmd.RunSQL ("update temppermit set vintage" & i & "=" & rstmerge2![vintage] & "")
                        DoCmd.RunSQL ("update temppermit set suppname" & i & "='" & Trim(rstmerge2![suppname]) & "'")
                        DoCmd.RunSQL ("update temppermit set techdesc" & i & "='" & Trim(rstmerge2![techdesc]) & "'")
                        'DoCmd.RunSQL ("update temppermit set fob" & i & "=" & rstmerge2![fob] & "")
                        DoCmd.RunSQL ("update temppermit set cpage=" & vpage & "")
                        DoCmd.RunSQL ("update temppermit set tpage=" & vpage2 & "")
                        i = i + 1
                        rcount = rcount + 1
                    End If
                    rstmerge2.MoveNext
                Loop
                If (i = 6) Or (rcount = vcountp) Then
                    ' msgbox print doc
                    i = 1
                End If
                vpage = vpage + 1
                
            Loop
            If rstmerge.EOF = True Then
                MsgBox "eof"
            End If
            rstmerge2.Close

any clue? thx, max.
 
In the line "Do While (Not rstmerge2.EOF) Or (rcount <> vcountp)"
you are testing with OR, if one of the expressions is true the loop will continue, and I don't see vcount set so this expression is always true.
 
PeterF said:
In the line "Do While (Not rstmerge2.EOF) Or (rcount <> vcountp)"
you are testing with OR, if one of the expressions is true the loop will continue, and I don't see vcount set so this expression is always true.


good point
lets see if this chg makes my life easier

thx, max.
 
Before doing anything, I would check your update statements too. At the moment they have no where clause so will change EVERY value in the table you are updating to the one you are setting..... just a quick warning :)
 
workmad3 said:
Before doing anything, I would check your update statements too. At the moment they have no where clause so will change EVERY value in the table you are updating to the one you are setting..... just a quick warning :)


workmad3, thx for your advise. i am updating a temporary table with only one record.
thx.
 
adaniele said:
good point
lets see if this chg makes my life easier

thx, max.

peterf, nothing changed. a msg appears "object required"

thx, max.
 
solved

hey guys, i found a workarround.
i dont need to ask for the EOF. I know how many records i have to read , so once i read them, i am out of the loop.
thx, max.
 

Users who are viewing this thread

Back
Top Bottom