Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2005
    Posts
    183

    Unanswered: recordset EOF issues / while..wend

    Observe the snippet of code below.

    My problem arises with:
    rs_INDREudvalg.Move (ydreteller + 1)
    While rs_INDREudvalg.EOF <> True

    In cases where the rs_INDREudvalg recordset only contains 2 records, the While statement received TRUE and doesn't run the subsequent code, and the comparison between the arrays isn't performed.

    How would I get about this? the reason for the initial rs move, is that I don't want to compare the first recordsets with each other, as they are the same.

    Thanks in advance,

    Trin



    Code:
        While rs_unikke.EOF <> True
            
            udvalgkald = "ket.DOUBLERIGHTS_sp_udvalgaflinjer " & rs_unikke!Plademærkenummer.Value
                
            rs_YDREudvalg.Open udvalgkald, Cnxn, adOpenStatic, adLockReadOnly
                
            rs_INDREudvalg.Open udvalgkald, Cnxn, adOpenStatic, adLockReadOnly
                
            ydreteller = 1
                
            While rs_YDREudvalg.EOF <> True
                
                rs_INDREudvalg.MoveFirst
                
                udvalg_setA = Array(rs_YDREudvalg!Plademærkenummer.Value, rs_YDREudvalg![Fra dato].Value, rs_YDREudvalg![Til dato].Value, rs_YDREudvalg![Selskabsnummer].Value)
                
                'MsgBox "Array A " & udvalg_setA(0) & "," & udvalg_setA(1) & "," & udvalg_setA(2) & "," & udvalg_setA(3), vbOKOnly
                                
                rs_INDREudvalg.Move (ydreteller + 1)
                                
                While rs_INDREudvalg.EOF <> True
                    
                    udvalg_setB = Array(rs_INDREudvalg!Plademærkenummer.Value, rs_INDREudvalg![Fra dato].Value, rs_INDREudvalg![Til dato].Value, rs_INDREudvalg![Selskabsnummer].Value)
                    
                        'MsgBox "Array B " & udvalg_setB(0) & "," & udvalg_setB(1) & "," & udvalg_setB(2) & "," & udvalg_setB(3), vbOKOnly
                    
                        If udvalg_setA(2) > udvalg_setB(1) Then
                            
                            DoCmd.SetWarnings False
                            
                            SQL = "INSERT into DOUBLERIGHTS_overlaptabel VALUES(" & Str(Trim(rs_unikke!Plademærkenummer.Value)) & "," & Str(udvalg_setA(3)) & "," & Str(udvalg_setB(3)) & ",'erstat','erstat')"
                                
                            MsgBox "" & SQL & "", vbOKOnly
                                
                            DoCmd.RunSQL SQL
                                
                            DoCmd.SetWarnings True
                        
                        End If
                
                    rs_INDREudvalg.MoveNext
                
                Wend
                
                ydreteller = ydreteller + 1
                
                rs_YDREudvalg.MoveNext
                
            Wend
            
            rs_unikke.MoveNext
            rs_YDREudvalg.Close
            rs_INDREudvalg.Close
            
        Wend
    IT squid: networks, servers, firewalls, routers and I dabble a little with SQL-server and Access as well....

  2. #2
    Join Date
    Oct 2005
    Posts
    183
    never mind.. solved it with a boring if statement..

    Code:
            While rs_YDREudvalg.EOF <> True
                
                rs_INDREudvalg.MoveFirst
                
                udvalg_setA = Array(rs_YDREudvalg!Plademærkenummer.Value, rs_YDREudvalg![Fra dato].Value, rs_YDREudvalg![Til dato].Value, rs_YDREudvalg![Selskabsnummer].Value)
                
                While rs_INDREudvalg.EOF <> True
                
                    If ydreteller = 1 Then
                        ydreteller = ydreteller + 1
                        rs_INDREudvalg.Move ydreteller
                    End If
    IT squid: networks, servers, firewalls, routers and I dabble a little with SQL-server and Access as well....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •