|
-
Dec 2nd, 2002, 07:21 PM
#1
Thread Starter
Member
Can't figure it out
Hello to all,
Here is what I am looking for.
Step A
========
I checked off all the customers in the list. Some customers may have an address while others don't. When I click the Print button, **only** customers with valid addresses will be printed out. That's when I called --->> Call GetCustomerBookMark(k)
Step B
========
On the other hand, If I clicked on the list and selected customers without no addresses, then no letters will be printed out for those customers. That's when I **DON'T called --->> Call GetCustomerBookMark(k). I just exit out. These are validation I am doing on the Print Button. See sample below.
My code works for Step A. How do you changed it to work for
Both Step A and Step B.
Data in the ListView
Names Address City State Zip
===================================
[X] Don Joe **has no address **
[X] Ben Joe **has no address**
[X] Sally 1 Pine Street
[X] Jorge 3030 Mapel Street
With the code below, letters will be printed for
Sally and Jorge only because they have an address.
See code below which works for Step A.
Private sub PrintCustomer()
call VerifyAddress
end Sub
Private Sub VerifyAddress()
Dim k As Integer
Dim intpos As Integer
Dim CustID As Long
Dim strCustNames As String
Dim strMsg As String
If Me.LvwCustomer.ListItems.Count > 0 Then
For k = 1 To Me.LvwCustomer.ListItems.Count
If Me.LvwCustomer.ListItems.Item(k).Checked Then
intpos = InStr(1, Me.LvwCustomer.ListItems.Item(k).Key, "C", vbTextCompare)
'use for other uses.
CustID = CLng(Mid(Me.LvwCustomer.ListItems.Item(k).Key, 2, Len(Me.LvwCustomer.ListItems.Item(k).Key) - intpos))
If Len(Trim(Me.LvwCustomer.ListItems.Item(k).SubItems(5))) = 0 And _ 'address
Len(Trim(Me.LvwCustomer.ListItems.Item(k).SubItems(6))) = 0 And _ 'apt
Len(Trim(Me.LvwCustomer.ListItems.Item(k).SubItems(7))) = 0 And _ 'City
Len(Trim(Me.LvwCustomer.ListItems.Item(k).SubItems(8))) = 0 And _ 'state
Len(Trim(Me.LvwCustomer.ListItems.Item(k).SubItems(9))) = 0 And _ 'zip
Len(Trim(Me.LvwCustomer.ListItems.Item(k).SubItems(10))) = 0 Then 'country
'uncheck the Customer that has no address
Me.LvwCustomer.ListItems.Item(k).Checked = False
strCustNames = strWitNames & LvwCustomer.ListItems.Item(k) & vbTab & _
LvwCustomer.ListItems.Item(k).SubItems(1) & " " & LvwCustomer.ListItems.Item(k).SubItems(2)
If Len(Trim(strCustNames)) > 0 Then strWitNames = strCustNames & vbCrLf
strMsg = ("No letters will be printed for the following Customer") & vbCrLf & "" _
& "____________________________________________ " & vbCrLf & strCustNames & vbCrLf
End If
Call GetCustomerBookMark(k)
End If
Next k
MsgBox strMsg, vbInformation + vbOKOnly, "No Letters Printed"
End If
End Sub
I have a hard time getting it to work.
thanks a bunch.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|