Solved

Add syscmd meter to the following code.

Posted on 1998-09-05
6
368 Views
Last Modified: 2006-11-17
Using Access97.  Shown below is code taken from my database, which creates email messages and places them in the Outlook Outbox.  I need to add a syscmd meter to the code to show progress.  Not in the status bar, but the msgbox sort of thing.

Could you edit the code so that when it runs, a meter will shown in the middle of the screen to indicate progress.  Also, you must include a comment above each of your additions explaining what the code does, for it to be of use to me.


Code follows:

Sub SendMessage(DisplayMsg As Boolean, Optional AttachmentPath)
         
          Dim objOutlook As Outlook.Application
          Dim objOutlookMsg As Outlook.MailItem
          Dim objOutlookRecip As Outlook.Recipient
          Dim objOutlookAttach As Outlook.Attachment
        Dim dbs As Database, rst As Recordset
        Dim counter
       
    If IsNull(Me.txtSubject) Then
        MsgBox "You must enter a subject before despatching e-mails!"
        Me.txtSubject.SetFocus
        Exit Sub
    End If

    If IsNull(Me.txtNotice) Then
        MsgBox "You must enter text before despatching e-mail!"
        Me.txtNotice.SetFocus
        Exit Sub
    End If

    ' Return reference to current database.
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("tempFaxtest")
    ' Populate Recordset object.
    rst.MoveLast
    ' Return to first record.
    rst.MoveFirst


          ' Create the Outlook session.
          Set objOutlook = CreateObject("Outlook.Application")
            Do While Not rst.EOF
          ' Create the message.
          Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
       
              With objOutlookMsg
              ' Add the To recipient(s) to the message.
              'Set objOutlookRecip = .Recipients.Add(Me![txtemailaddress])
             Set objOutlookRecip = .Recipients.Add(rst.resemailtest)
             
              objOutlookRecip.Type = olTo

             
             ' Set the Subject, Body, and Importance of the message.
             .Subject = [txtSubject]
             .Body = [txtNotice]
             .Importance = olImportanceHigh  'High importance

             ' Add attachments to the message.
             If Not IsMissing(AttachmentPath) Then
                 Set objOutlookAttach = .Attachments.Add(AttachmentPath)
             End If

           
             ' Should we display the message before sending?
             If DisplayMsg Then
                 .Display

             Else
                 .Send
             End If
          End With
                     
    counter = counter + 1
    rst.MoveNext
    Loop
    Set objOutlook = Nothing
    MsgBox "There was " & counter & " e-mails sent!"
    rst.Close
    Set dbs = Nothing
End Sub
0
Comment
Question by:joslad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 2

Author Comment

by:joslad
ID: 1961318
Edited text of question
0
 
LVL 2

Author Comment

by:joslad
ID: 1961319
Edited text of question
0
 

Expert Comment

by:andre29
ID: 1961320
Are you gonna be using the progress bar meter active x?
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 2

Author Comment

by:joslad
ID: 1961321
Yep.  I have the developers version of Office97.


0
 
LVL 8

Accepted Solution

by:
Helicopter earned 200 total points
ID: 1961322
 Set dbs = CurrentDb
        Set rst = dbs.OpenRecordset("tempFaxtest")
        ' Populate Recordset object.
        rst.MoveLast
        ' Return to first record.
'******************************
'open the form with the progress bar (in my case frmProgress) Obviously this form should be set to resemble the ones Microsoft use

DoCmd.OpenForm ("frmProgress")
Dim f As Form
Set f = Forms!frmprogress
f!prog.Max =rst.recordcount 'I called my progress bar "prog"
************************************************        


rst.MoveFirst



{your code}

.
counter = counter + 1
**********************************************        
Forms!frmprogress.prog.Value = counter  'update the display
**********************************************
rst.MoveNext
Loop

Set objOutlook = Nothing

******************************
DoCmd.Close acForm, "frmProgress"

******************************        
MsgBox "There was " & counter & " e-mails sent!"
rst.Close
Set dbs = Nothing



0
 
LVL 2

Author Comment

by:joslad
ID: 1961323
Excellent answer and works perfectly.  Thanks Helicopter...

regards

0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question