PC Review


Reply
Thread Tools Rate Thread

Auto Email Help

 
 
Apprentice
Guest
Posts: n/a
 
      19th Feb 2009
I've been fighting this code for way too long, can someone help? Trying to
send an email from access and it hangs on this line:

Set rs = db.OpenRecordset(sql, dbOpenSnapshot)

I have DAO Library referenced and can't get past this line

Private Sub Form_Close()
Me.Dirty = False
Dim db As Database
Dim rs As DAO.Recordset
Dim ToVar As String
Dim sql As String
sql = "SELECT EmailAddress FROM %Staff " & "Where StaffMember Like '" &
Me.ActivityLead & "'"
Set db = CurrentDb
Set rs = db.OpenRecordset(sql, dbOpenSnapshot)

Do Until rs.EOF
ToVar = ToVar & rs!EmailAddress & ";"
rs.MoveNext
Loop

DoCmd.SendObject acSendNoObject, , , ToVar, , , "New Activity Assignment",
"A new Activity has been assigned to you in the Review Tracker", True


End Sub

--
Your guidance is greatly appreciated!
 
Reply With Quote
 
 
 
 
Pendragon
Guest
Posts: n/a
 
      19th Feb 2009
What is the error message? Have you tried dropping the dbOpenSnapshot and
simply having Set rs = db.OpenRecordset(sql)? All of my code with recordsets
is simply either a coded Select statement or a string variable (like yours)
and then manipulate the data as you have done.

"Apprentice" wrote:

> I've been fighting this code for way too long, can someone help? Trying to
> send an email from access and it hangs on this line:
>
> Set rs = db.OpenRecordset(sql, dbOpenSnapshot)
>
> I have DAO Library referenced and can't get past this line
>
> Private Sub Form_Close()
> Me.Dirty = False
> Dim db As Database
> Dim rs As DAO.Recordset
> Dim ToVar As String
> Dim sql As String
> sql = "SELECT EmailAddress FROM %Staff " & "Where StaffMember Like '" &
> Me.ActivityLead & "'"
> Set db = CurrentDb
> Set rs = db.OpenRecordset(sql, dbOpenSnapshot)
>
> Do Until rs.EOF
> ToVar = ToVar & rs!EmailAddress & ";"
> rs.MoveNext
> Loop
>
> DoCmd.SendObject acSendNoObject, , , ToVar, , , "New Activity Assignment",
> "A new Activity has been assigned to you in the Review Tracker", True
>
>
> End Sub
>
> --
> Your guidance is greatly appreciated!

 
Reply With Quote
 
Stuart McCall
Guest
Posts: n/a
 
      19th Feb 2009
"Apprentice" <(E-Mail Removed)> wrote in message
news:7DC3552D-8865-4379-87DC-(E-Mail Removed)...
> I've been fighting this code for way too long, can someone help? Trying
> to
> send an email from access and it hangs on this line:
>
> Set rs = db.OpenRecordset(sql, dbOpenSnapshot)
>
> I have DAO Library referenced and can't get past this line
>
> Private Sub Form_Close()
> Me.Dirty = False
> Dim db As Database
> Dim rs As DAO.Recordset
> Dim ToVar As String
> Dim sql As String
> sql = "SELECT EmailAddress FROM %Staff " & "Where StaffMember Like '" &
> Me.ActivityLead & "'"
> Set db = CurrentDb
> Set rs = db.OpenRecordset(sql, dbOpenSnapshot)
>
> Do Until rs.EOF
> ToVar = ToVar & rs!EmailAddress & ";"
> rs.MoveNext
> Loop
>
> DoCmd.SendObject acSendNoObject, , , ToVar, , , "New Activity Assignment",
> "A new Activity has been assigned to you in the Review Tracker", True
>
>
> End Sub
>
> --
> Your guidance is greatly appreciated!


If this:

%Staff

isn't just a typo, then it may be the problem. Try this:

Create a new query
Include the %Staff table
Add all the fields
Close and save the query as qryStaff
Use qryStaff instead of %Staff in your sql


 
Reply With Quote
 
Apprentice
Guest
Posts: n/a
 
      20th Feb 2009
Thanks to both Pendragon and Mr. McCall, I used both suggestions and its
ticking perfect now. Thanks alot! Here is the completed code for others:

Private Sub Form_Close()
Me.Dirty = False
Dim db As Database
Dim rs As DAO.Recordset
Dim ToVar As String
Dim sql As String
sql = "SELECT EmailAddress FROM AutoEmailQuery" & "Where StaffMember Like '"
&
Me.ActivityLead & "'"
Set db = CurrentDb
Set rs = db.OpenRecordset(sql)

Do Until rs.EOF
ToVar = ToVar & rs!EmailAddress & ";"
rs.MoveNext
Loop

DoCmd.SendObject acSendNoObject, , , ToVar, , , "New Activity Assignment",
"A new Activity has been assigned to you in the Review Tracker", True


End Sub

--
Your help was greatly appreciated!


"Stuart McCall" wrote:

> "Apprentice" <(E-Mail Removed)> wrote in message
> news:7DC3552D-8865-4379-87DC-(E-Mail Removed)...
> > I've been fighting this code for way too long, can someone help? Trying
> > to
> > send an email from access and it hangs on this line:
> >
> > Set rs = db.OpenRecordset(sql, dbOpenSnapshot)
> >
> > I have DAO Library referenced and can't get past this line
> >
> > Private Sub Form_Close()
> > Me.Dirty = False
> > Dim db As Database
> > Dim rs As DAO.Recordset
> > Dim ToVar As String
> > Dim sql As String
> > sql = "SELECT EmailAddress FROM %Staff " & "Where StaffMember Like '" &
> > Me.ActivityLead & "'"
> > Set db = CurrentDb
> > Set rs = db.OpenRecordset(sql, dbOpenSnapshot)
> >
> > Do Until rs.EOF
> > ToVar = ToVar & rs!EmailAddress & ";"
> > rs.MoveNext
> > Loop
> >
> > DoCmd.SendObject acSendNoObject, , , ToVar, , , "New Activity Assignment",
> > "A new Activity has been assigned to you in the Review Tracker", True
> >
> >
> > End Sub
> >
> > --
> > Your guidance is greatly appreciated!

>
> If this:
>
> %Staff
>
> isn't just a typo, then it may be the problem. Try this:
>
> Create a new query
> Include the %Staff table
> Add all the fields
> Close and save the query as qryStaff
> Use qryStaff instead of %Staff in your sql
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook 2003 does not auto poll/auto send/receive email jodie.berger1@gmail.com Microsoft Outlook Discussion 2 13th Mar 2008 07:14 PM
auto add email addresses to address book when replying a email =?Utf-8?B?QXBhY2hlMw==?= Microsoft Outlook Discussion 5 5th Feb 2006 07:38 PM
Auto Name Checking should auto select EMAIL and not display FAX =?Utf-8?B?U2xvb3BlcjI=?= Microsoft Outlook Discussion 0 4th Jan 2006 07:00 PM
In Outlook, if a rule auto-deletes an email, the new email flag i. =?Utf-8?B?T3V0bG9vaw==?= Microsoft Outlook Discussion 0 4th Mar 2005 01:21 PM
email address auto-complete populated incorrect email details =?Utf-8?B?cm9uZ2Fu?= Microsoft Outlook Discussion 7 31st Oct 2003 11:47 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:57 PM.