Advertisement

05.15.2008 at 02:15PM PDT, ID: 23406718
[x]
Attachment Details

Form_Timer while another event runs - VBA MS Access

Asked by fcoit in Access Coding/Macros

Hi there,

I have a form that has a label that reads "Processing", on the timer event I have copied from another tread the code that simulates the flashing effect.  If the forms opens normally by itsel it works fine, but I want it to run while another event is running.  The other event changes the TimerInterval so it the label initiates "flashing", but it does not work.  I have included the code to give you a better idea of what I want to do.  Any help will be greatly appreciated.  Thank youStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
Private Sub Form_Timer()
 
    Static intShowStatus As Integer
    If intShowStatus Then
        ' Show status.
        lblStatus.Visible = True
    Else
        ' Don't show icon.
        lblStatus.Visible = False
    End If
    intShowStatus = Not intShowStatus
 
End Sub
 
 
 
Function MailBoxOwner()
On Error GoTo errHandler
 
'Declare objects & variants
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim strMailBoxOwner As String
Dim strMailBoxOwnerTemp As String
Dim strEmail As String
Dim fMain As Form
 
'Set objects & variants
Set db = CurrentDb()
 
strSQL = "SELECT MailBox, EMAIL " _
      & "FROM tbl_OUTLOOK_DELEGATE_ACCESS " _
      & "GROUP BY MailBox,EMAIL " _
      & "ORDER BY MailBox "
 
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
Set fMain = Forms("frmMain")
 
fMain.ProgressBarA.Visible = True
fMain.ProgressBarB.Visible = True
fMain.lblStatus.Visible = True
fMain.TimerInterval = 100
 
'Loop thru recordset to populate the word document
With rs
    .MoveFirst
    Do Until rs.EOF
        strMailBoxOwner = rs!MailBox
        strEmail = rs!Email
        'Progress bar update
        fMain.ProgressBarB.Width = (fMain.ProgressBarA.Width / .RecordCount) * .AbsolutePosition
        'Added
        DoEvents
        ' Repaint the current form.
        fMain.Repaint
        'Added ************************
        
        .MoveNext
        CreateWordDoc strMailBoxOwner, strEmail
        For lCounter = 1 To 750000: Next 'Added ************************
    Loop
End With
 
'***************************************************************
' If you're at the end of the Customers recordset, then fill the
' progress bar completely and repaint the form.
 
If rs.EOF Then
fMain.ProgressBarB.Width = rs.RecordCount
fMain.Repaint
fMain.TimerInterval = 0
fMain.cmdReset.Visible = True
fMain.lblStatus.Visible = True
fMain.lblStatus.Caption = "Done!"
fMain.ProgressBarA.Visible = False
fMain.ProgressBarB.Visible = False
  
' Set the progress bar's width to zero. Repaint the form.
'ProgressBarB.Width = 0
fMain.Repaint
fMain.lblExecute.Visible = False
    
End If
'***************************************************************
' Close the recordset.
rs.Close
 
exitHere:
    'Empty objects
    Set db = Nothing
    Set rs = Nothing
    Exit Function
    
errHandler:
    MsgBox "Error: " & Err.Number & vbNewLine & "Description: " & Err.Description & "", vbInformation, "Populate Letter"
    GoTo exitHere
 
 
 
End Function
 
Loading Advertisement...
 
[+][-]05.15.2008 at 02:36PM PDT, ID: 21578189

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 04:02PM PDT, ID: 21578636

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Access Coding/Macros
Sign Up Now!
Solution Provided By: harfang
Participating Experts: 1
Solution Grade: A
 
 
[+][-]05.16.2008 at 04:24PM PDT, ID: 21587168

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.16.2008 at 05:29PM PDT, ID: 21587506

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628