[AccessD] Help with Mah Arithmetic

John Ruff papparuff at attbi.com
Wed Jun 11 19:23:29 CDT 2003


Why not just iterate through the items selected without worrying about
count.

    Dim varItm as variant
 
    With ctl
        For Each varItm In .ItemsSelected
            lng_PK_Of_Interest = .Column(0, varItm)
            Debug.Print "Creating mail for Practicum Placement #: " &
lng_PK_Of_Interest
		Send_Text_PMail lng_PK_Of_Interest        
	  Next varItm
    End With

Or, to do it with the code you already have:

        For intPhysicalRow = 0 To .ItemsSelected.Count - 1
            intCurrentRow = ctl.ItemsSelected(intPhysicalRow)
		' This If statement is causing the problem.
		' The count of .ItemsSelected is 0 based, not 1 based
            ' If intPhysicalRow > 0 Then
                lng_PK_Of_Interest = ctl.Column(0, intCurrentRow)
                Debug.Print "Creating mail for Practicum Placement #: "
& lng_PK_Of_Interest
                Send_Text_PMail lng_PK_Of_Interest
		' End If
        Next intPhysicalRow     



John V. Ruff - The Eternal Optimist :-)
Always Looking For Contract Opportunities

Home: 253.588.2139
Cell: 253.307.2947
9306 Farwest Dr SW
Lakewood, WA 98498

"Commit to the Lord whatever you do,
                and your plans will succeed." Proverbs 16:3



-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Arthur Fuller
Sent: Wednesday, June 11, 2003 3:17 PM
To: AccessD
Subject: [AccessD] Help with Mah Arithmetic


I've been staring at the following code and toying with this and that
and now I'm so punchy I really need a fresh set of eyes.

Scenario:

- a listbox with extended select, pk in column(0)
- a proc that works, called from the loop presented below
- said listbox has headings ON

<code>
'-----------------------------------------------------------------------
----
------------
' Procedure : Send_Text_Confirmations
' DateTime  : 6/11/2003 14:50
' Author    : Arthur Fuller
' Purpose   : Send confirmations not using Snapshot files, send
generated
text instead
'           : This code sends text email messages constaining the same
data
as the snapshot
'           : We use the report's data source directly to retrieve the
information we need.
'-----------------------------------------------------------------------
----
------------
'
Private Sub Send_Text_Confirmations()
  Dim ctl As Control
  Dim intPhysicalRow As Integer, intCurrentRow As Integer
  Dim strWhere As String
  Dim strReportName As String
  Dim lng_PK_Of_Interest As Long
  
  With Me
    Set ctl = .Item_Selector_listbox
    With ctl
    'column headings seem to screw this code up but I can't figure out
how
    'to account for them
      For intPhysicalRow = 0 To .ItemsSelected.Count - 1
        intCurrentRow = ctl.ItemsSelected(intPhysicalRow)
        If intPhysicalRow > 0 Then
          lng_PK_Of_Interest = ctl.Column(0, intCurrentRow)
          Debug.Print "Creating mail for Practicum Placement #: " &
lng_PK_Of_Interest
          Send_Text_PMail lng_PK_Of_Interest
        End If
        Next intPhysicalRow
    End With
    MsgBox "Emails sent for " & ctl.ItemsSelected.Count & " Practica",
vbInformation, "Task Complete"
  End With

  On Error GoTo 0
  Exit Sub

Send_Text_Confirmations_Error:

  MsgBox "Error " & Err.Number & vbCrLf & _
           Err.Description & vbCrLf & _
           "in procedure Send_Text_Confirmations of VBA Document
Form_frm_Practica_Email_Select", _
           vbCritical, _
           "Program Error"
End Sub
</code


The line 
	Send_Text_PMail lng_PK_Of_Interest

Works and is not of interest. Just assume that whatever it does, it
works. The problem is in the arithmetic and I cannot see it. 

Well, ok, I'm old, and entitled to more senior moments than you :-)

Symptoms:
Select 3 items. It does 2. Select 1. It does none. Select All and it
works. Headings off and on affect the results. I want the code to
interrogate HeadingsOn but can't seem to find the attribute.

Revisions invited!

Arthur


_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list