Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Wed, 17 Sep 2008 07:41:37 -0700 (PDT),    group: microsoft.public.word.vba.general        back       


Sort Loop Problem   
I'm trying to create a file of employees with their dependents. I have
created this procedure to sort the people but I'm getting duplicate
dependents in some cases but not all. I'll appreciate any input.
Thanks.

Private Sub ExportMain()
    Dim LogFile As Integer
    LogFile = FreeFile
    Dim LogFileName As String
    LogFileName = "C:\EligFile.txt"
    Dim DepNotFound As Boolean

    Dim rstMain As Recordset
    Dim rstDep As Recordset

    Dim db As Database
    Set db = CurrentDb()


    Set rstMain = db.OpenRecordset("tblMainParts")
    Set rstDep = db.OpenRecordset("tblDeps2")
    Open LogFileName For Append As #LogFile
    Do While Not rstMain.EOF

        'Main Subscriber
        Print #LogFile, Left(rstMain!Field1 & Space(680), 680)

        'Move through dependent records until Dep SSN matches with
Main SSN
        Do While Left(rstMain!Field1, 9) <> Left(rstDep!Field1, 9)
            rstDep.MoveNext
            If (rstDep.EOF = True) Then
                DepNotFound = True
                Exit Do
            Else
                DepNotFound = False
            End If
        Loop

        'Write Dependent records while Dep SSN matches with Main SSN
        If (DepNotFound = False) Then
            Do While (Left(rstMain!Field1, 9) = Left(rstDep!Field1,
9))
                Print #LogFile, Left(rstDep!Field1 & Space(680), 680)
                rstDep.MoveNext
                If (rstDep.EOF = True) Then
                    Exit Do
                End If
            Loop
        End If
        rstMain.MoveNext
        rstDep.MoveFirst
    Loop

    Close #LogFile

End Sub
date: Wed, 17 Sep 2008 07:41:37 -0700 (PDT)   author:   ravxm

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us