Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Add syscmd meter to the following code.

Posted on 1998-09-05
6
Medium Priority
?
389 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 2

Author Comment

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


0
 
LVL 8

Accepted Solution

by:
Helicopter earned 800 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

971 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