COMPILE ERROR LOOP WITHOUT DO wHEN I RUN THE PROGRAM IT SAYS LOOP WITHOUT DO AND POI

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • iamahmar
    New Member
    • Nov 2013
    • 1

    COMPILE ERROR LOOP WITHOUT DO wHEN I RUN THE PROGRAM IT SAYS LOOP WITHOUT DO AND POI

    Code:
    Sqlquery = "select * from general_journal_temp_TBL "
       Set Rs = db.OpenRecordset(Sqlquery1, dbOpenDynaset)
       If Not Rs.EOF Then
          Do While Not Rs.EOF
          
             Sqlquery1 = "select * from general_journal_TBL where journal_no = val('" & Rs!Journal_NO & "') and entry_type = val ('" & Rs!entry_type & "') and ac_no = '" & Rs!account_no & "' "
             Set Rs1 = db.OpenRecordset(Sqlquery1, dbOpenDynaset)
             If Rs1.EOF Then
          
             Rs1.AddNew
             
             Rs1!Journal_NO = Rs!Journal_NO
             Rs1!Journal_Date = Rs!Journal_Date
             Rs1!journal_descrition = Rs!journal_descrition
             Rs1!journal_Type = Rs!journal_Type
             Rs1!journal_type_no = Rs!journal_type_no
             Rs1!journal_type_date = Rs!journal_type_date
             Rs1!entry_type = Rs!entry_type
             Rs1!AC_NO = Rs!AC_NO
             Rs1!AC_date = Rs!AC_date
             Rs1!amount_dr = Rs!amount_dr
             Rs1!amount_cr = Rs!amount_cr
             Rs1!details = Rs!details
             
             Rs1.Update
                 
             Rs.MoveNext
          Loop
             End If
       End If
    Last edited by Rabbit; Nov 12 '13, 04:49 PM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.
  • MikeTheBike
    Recognized Expert Contributor
    • Jun 2007
    • 640

    #2
    Hi

    I thinkmit woukd help you greatly (and use) if indented you code and used code tag in ypu post. This would the indicated that you have the Loop and End Ifs in the wrong order ie.
    Code:
    If Not Rs.EOF Then
        Do While Not Rs.EOF
            Sqlquery1 = "select * from general_journal_TBL where journal_no = val('" & Rs!Journal_NO & "') and entry_type = val ('" & Rs!entry_type & "') and ac_no = '" & Rs!account_no & "' "
            Set Rs1 = Db.OpenRecordset(Sqlquery1, dbOpenDynaset)
            If Rs1.EOF Then
                Rs1.AddNew
                
                Rs1!Journal_NO = Rs!Journal_NO
                Rs1!Journal_Date = Rs!Journal_Date
                Rs1!journal_descrition = Rs!journal_descrition
                Rs1!journal_Type = Rs!journal_Type
                Rs1!journal_type_no = Rs!journal_type_no
                Rs1!journal_type_date = Rs!journal_type_date
                Rs1!entry_type = Rs!entry_type
                Rs1!AC_NO = Rs!AC_NO
                Rs1!AC_date = Rs!AC_date
                Rs1!amount_dr = Rs!amount_dr
                Rs1!amount_cr = Rs!amount_cr
                Rs1!Details = Rs!Details
                
                Rs1.Update
                Rs.MoveNext
            End If
        Loop
    End If
    HTH

    Note I haven't checked anything else.

    MTB

    Comment

    Working...