Results 1 to 6 of 6

Thread: *RESOLVED*Whats wrong with my code- Please have a look!!

Threaded View

  1. #1

    Thread Starter
    Frenzied Member mxnmx's Avatar
    Join Date
    Dec 2001
    Location
    I'm back...now!!!
    Posts
    1,396

    *RESOLVED*Whats wrong with my code- Please have a look!!

    Here;s my code and I get am error: NEXT WITHOUT FOR...pls have a look...

    VB Code:
    1. n = 0
    2. conDB
    3. Set oRs = New Recordset
    4. strSql = "Select * from Transactions where Status='Unpaid'"
    5. oRs.Open strSql, goCnn, adOpenKeyset, adLockOptimistic, adCmdText
    6. x = oRs.RecordCount
    7. axn
    8. Do While Not oRs.EOF
    9.  
    10. strItem = oRs("Group Name")
    11. Set oRst = New Recordset
    12. strsql1 = "Select * from Transactions where [Group Name]='" & strItem & "'" & " And status='Unpaid'"
    13. oRst.Open strsql1, axnCnn, adOpenKeyset, adLockOptimistic
    14. Set oRsy = New Recordset
    15. strsql2 = "Select * from Groups where [Group Name]='" & strItem & "'"
    16. oRsy.Open strsql2, axnCnn, adOpenKeyset, adLockOptimistic
    17. y = oRst.RecordCount
    18.  
    19.  For i = 1 To y
    20.          If n = 0 Then
    21.          Set WordObject = CreateObject("Word.Application")
    22.     With WordObject
    23.         .Application.Documents.Add App.Path & "\Invoice.dot"
    24.         .Visible = True
    25.         .Activate
    26.         .ActiveDocument.Bookmarks("Date").Range.InsertAfter Format(Date, "DD/MM/YYYY")
    27.         .ActiveDocument.Bookmarks("GROUPNAME").Range.InsertAfter oRst("Group Name")
    28.         .ActiveDocument.Bookmarks("GROUPID").Range.InsertAfter oRst("GroupID")
    29.         .ActiveDocument.Bookmarks("Address").Range.InsertAfter oRsy("Address")
    30.         .ActiveDocument.Bookmarks("TELEPHONE").Range.InsertAfter oRsy("Phone")
    31.              
    32.         .Selection.MoveDown wdLine, 17
    33.         .Selection.MoveLeft wdCharacter, 2
    34.         Do While oRst.EOF = False
    35.             .Selection.TypeText oRst!Invoice_ID
    36.             .Selection.MoveRight wdCharacter, 1
    37.             .Selection.TypeText oRst!VisitDate
    38.             .Selection.MoveRight wdCharacter, 1
    39.             .Selection.TypeText oRst!TreatMent
    40.             .Selection.MoveRight wdCharacter, 1
    41.             .Selection.TypeText oRst!AmountCharged
    42.             .Selection.MoveRight wdCharacter, 1
    43.             .Selection.TypeText oRst!AmountPaid
    44.             .Selection.MoveRight wdCharacter, 1
    45.             .Selection.TypeText oRst!AmountToPay
    46.             .Selection.MoveRight wdCharacter, 1
    47.             .Selection.TypeText oRst!Status
    48.             oRst.MoveNext
    49.             If oRst.EOF = False Then
    50.                 .Application.ActiveDocument.Tables(2).Rows.Add
    51.                 .Selection.MoveDown wdLine, 1
    52.                 .Selection.MoveLeft wdCharacter, 6
    53.             End If
    54.          Loop
    55.     Next
    56.    End With
    57.    End If
    Last edited by mxnmx; Feb 14th, 2003 at 07:05 PM.
    Can't Remember Birthdays or Important Dates- Never Miss any Important Date(s)

Posting Permissions

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



Click Here to Expand Forum to Full Width