Hello, help please, I need to extract email address from a query result in a field text to use it as TO: in a sendobject command. I hava an error in sql statement, in access query desing data shows without any problem, but with vba code I got this error:
Runtime error '3265' Item not found in this collection, and error points to
Me.Para = Me.Para & "; " & rs!tPAEmails.email
VBA Code:
Private Sub Command12_Click()
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT tMain.FaxDocAge, tTeamLead.idTL, tPAEmails.Email FROM tPAEmails INNER JOIN ((tMain INNER JOIN tRegion ON tMain.District = tRegion.F1) INNER JOIN tTeamLead ON tRegion.TeamLead = tTeamLead.idTL) ON tPAEmails.ICCLogIn = tMain.LogonName WHERE (((tMain.FaxDocAge)>=4))")
Do While Not rs.EOF
If Me.Para = "" Then
Me.Para = rs!tPAEmails.email
Else
Me.Para = Me.Para & "; " & rs!tPAEmails.email
End If
rs.MoveNext
Loop
' end Concatenate Multiple Records to Text Field
jump_out:
rs.Close
Set rs = Nothing
End Sub
Access Design Query SQL working code:
SELECT tMain.FaxDocAge, tTeamLead.idTL, tPAEmails.Email
FROM tPAEmails INNER JOIN ((tMain INNER JOIN tRegion ON tMain.District=tRegion.F1) INNER JOIN tTeamLead ON tRegion.TeamLead=tTeamLead.idTL) ON tPAEmails.ICCLogIn=tMain.LogonName
WHERE (((tMain.FaxDocAge)>=4) And ((tTeamLead.idTL)=Forms!fMainScreen!TLCombo.value));
Any solution?
Thank you !!!
Runtime error '3265' Item not found in this collection, and error points to
Me.Para = Me.Para & "; " & rs!tPAEmails.email
VBA Code:
Private Sub Command12_Click()
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT tMain.FaxDocAge, tTeamLead.idTL, tPAEmails.Email FROM tPAEmails INNER JOIN ((tMain INNER JOIN tRegion ON tMain.District = tRegion.F1) INNER JOIN tTeamLead ON tRegion.TeamLead = tTeamLead.idTL) ON tPAEmails.ICCLogIn = tMain.LogonName WHERE (((tMain.FaxDocAge)>=4))")
Do While Not rs.EOF
If Me.Para = "" Then
Me.Para = rs!tPAEmails.email
Else
Me.Para = Me.Para & "; " & rs!tPAEmails.email
End If
rs.MoveNext
Loop
' end Concatenate Multiple Records to Text Field
jump_out:
rs.Close
Set rs = Nothing
End Sub
Access Design Query SQL working code:
SELECT tMain.FaxDocAge, tTeamLead.idTL, tPAEmails.Email
FROM tPAEmails INNER JOIN ((tMain INNER JOIN tRegion ON tMain.District=tRegion.F1) INNER JOIN tTeamLead ON tRegion.TeamLead=tTeamLead.idTL) ON tPAEmails.ICCLogIn=tMain.LogonName
WHERE (((tMain.FaxDocAge)>=4) And ((tTeamLead.idTL)=Forms!fMainScreen!TLCombo.value));
Any solution?
Thank you !!!