jasmeetsingh89
New member
- Local time
- Today, 15:42
- Joined
- Aug 2, 2012
- Messages
- 8
Hi,
I am cracking my brains on something that most of you'll must be finding very trivial ...
As far as i know .. my code is fine but i keep getting this error "Compile Error: Invalid Qualifier".
The error is on the underlined line .... please help ! !
my code is :
I am cracking my brains on something that most of you'll must be finding very trivial ...
As far as i know .. my code is fine but i keep getting this error "Compile Error: Invalid Qualifier".
The error is on the underlined line .... please help ! !
my code is :
Private Sub Command3_Click()
Dim DB As DAO.Database
Dim rs As DAO.Recordset
Dim rs_filtered As DAO.Recordset
Dim STR_SQL As String
Dim recCount As Long
Dim i As Long
STR_SQL = Me.RecordSource.Value
Set rs = DB.OpenRecordset(STR_SQL, , dbOpenDynaset, dbReadOnly)
rs.Filter = "[Year_Of_Admit] = " & Combo_year.Value
Set rs_filtered = rs.OpenRecordset
If Not rs_filtered.EOF Then
rs_filtered.MoveLast
rs_filtered.MoveFirst
recCount = rs_filtered.RecordCount
Else
MsgBox "There are no students"
Exit Sub
End If
Dim oOutlook As Outlook.Application
Dim oEmailItem As MailItem
For i = 0 To i = (recCount - 1)
On Error Resume Next
Set oOutlook = GetObject(, "Outlook.Application")
If oOutlook Is Nothing Then Set oOutlook = CreateObject("Outlook.Application")
Set oEmailItem = oOutlook.CreateItem(olMailItem)
With oEmailItem
.Attachments.Add "E:\MSKCC Internship\QUESTIONS FOR SANDRA.docx"
.To = rs_filtered![Therapist_Email]
'.Display
.Subject = "Testing Email"
.Send
End With
Set oEmailItem = Nothing
Set oOutlook = Nothing
rs_filtered.MoveNext
Next i
End Sub