Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

selective printing

Status
Not open for further replies.

brews

Technical User
Dec 12, 2007
194
US
Have a vb6 database program using an mdb as the data file. In one particular process I want to print selected records using a listview with check boxes.
selected.jpg


The code that causes the printing
Code:
Private Sub mnuFilePrint_Click()
    Set cCol = New Collection
    For Each xItem In lvwPrintNameTag.ListItems
        If xItem.Checked Then
            cCol.Add xItem.Text, xItem.Text
        End If
    Next
    If cCol.Count = 0 Then
        MsgBox "Nothing checked", vbInformation
        Exit Sub
    Else
        For i = 1 To cCol.Count
            iID = cCol.Item(i)
            cData.FindOneName iID, mMem
            mMem.PrintNameTag = True
            cData.UpdateMembers iID, mMem
            MsgBox iID
        Next i
End Sub
The problem is when the msgbox iID is removed the last record is not printed. If only one box is checked, therefore, nothing is printed.

This is a puzzlement to me and any help is appreciated. Thank you.
 
Change

Code:
iID = cCol.Item(i)
to
Code:
iID = cCol.Item(i-1)

I think the column range is outside of the loop scope. (I may be wrong though, as I never got home til after 5am!)

yosherrs.gif

[tt]'Very funny, Scotty... Now Beam down my clothes.'[/tt]
 
Do you get the same problem both in the IDE and with a compiled version of the program?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top