Solved

Add syscmd meter to the following code.

Posted on 1998-09-05
6
365 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

738 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