Solved

Add syscmd meter to the following code.

Posted on 1998-09-05
6
362 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
  • 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

821 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