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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Emailing to people selected in listbox

Status
Not open for further replies.

Eightball3

Programmer
Nov 23, 2002
138
US
First of all thanks to everyone here at Tek-Tips. This site is great!

I have a listbox that contains the names of people I would like to send an attached report via email to. The listbox is set to have multiple selections. I have a button at the botton of the screen that when pressed will initiate the emailings.

What I would like to have happen is that as each email is sent out, that selected person in the listbox unselects. The user would be able to see items unselecting as this process works. I have the emailing working except for the unselecting process...I just can't get that working. Below is my code. Can someone tell me where I'm going wrong at?


Dim ctrl As Control
Dim x As Integer
Dim y As Integer

If List0.ItemsSelected.Count > 0 Then
Set ctrl = [List0]
y = List0.ItemsSelected.Count
For x = y To 1 Step -1
If List0.ItemsSelected.Count = 0 Then
Else
Me![Activity] = ctrl.Column(1, List0.ItemsSelected(x - 1))
Me![POC] = ctrl.Column(0, List0.ItemsSelected(x - 1))
DoCmd.OpenForm "poc_form", acNormal, , , acFormEdit, acIcon
Forms![poc_form].RecordSource = "Email_Recall2"
If Forms![poc_form]![E_Mail_Recall] = "y" Then
Dim strREPORTNAME As String
Dim strTEMPFILENAME As String
strREPORTNAME = "Recall Notice"
strTEMPFILENAME = "C:\App\Recall.snp"
DoCmd.OutputTo acOutputReport, strREPORTNAME, acFormatSNP, strTEMPFILENAME, False 'don't start OLE app
Call SendMessage_Mail2
Else
DoCmd.OpenReport "Recall Notice", acViewNormal
End If
DoCmd.Close acForm, "poc_form"
List0.Selected(y) = False
End If
Next x
Set ctrl = Nothing
End If
 
DoCmd.Close acForm, "poc_form"
--------------------- from here tafter End IF
End If
List0.Selected(y) = False
Next x
Set ctrl = Nothing
End If

Cool code !

TIA
 
Hi TLady,
Thanks for the reply.

I tried moving the List0.Selected(y) = false line to outside the End If statement but it still doesn't work. I mis-typed that line in my original post it should read

List0.Selected(x)

Any more ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top