Chaining inspector forms

  • Thread starter Thread starter DaveChoiceTech
  • Start date Start date
D

DaveChoiceTech

I am trying to check the validity of data in a collection of
Appointment items between a specified date range.

When I find an invalid item I would like to open the appointment to
allow the user to correct the problem. After the appointment is saved
the program should reload and reinspect the collection of items.

This would be easy is inspectors could be modal but from previous
threads it is my understanding that this is not allowed for a AddIn

I tried using the Close Event for the Appointment item to restart the
inspection. This works but the item does not close since it is busy
doing the reinspection.

I need to allow the appointment item to complete closing and then
restart the inspection.

Does anyone have any idea how this can be done? Perhaps by some Post
Event approach?
 
Handle the Inspector.Close event. When one closes call the code to start
examining other items.
 
Perhaps I wasn't clear in my original post. I was handling the
Inspectors close event to call the code to examine the other items. My
problem was that that code would find the next item but still be in
process from the first item since it was called from the first item's
close event and is now being used to display the next item. The result
was that both items would now be on the screen. If there wrere multiple
problems I would wind up with bunch of screens.

Now that I think about it I could have probably worked around it as you
suggest by separating the code to examine the items from the code that
displays the problem items.

That would have been simple and is probably the reason I didn't think
of it. Instead I have solved my problem by using an "event queue" based
on the Windows API setimer function to allow the code to be called
asynchronously from the inspectors close event. For what it's worth,
here's the code.

Option Explicit

Public Declare Function SetTimer Lib "user32" (ByVal hwnd As Long,
ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As
Long) As Long
Public Declare Function KillTimer Lib "user32" (ByVal hwnd As Long,
ByVal nIDEvent As Long) As Long

'Set in InitHandler of OutAddIn and dereferenced in UnitHandler
Public g_objOutAddIn As OutAddIn

Private lngTimerId As Long
Private blnCallWaiting As Boolean

'Private objOutAddIn As OutAddIn
Private Sub StartTimer()
lngTimerId = SetTimer(0&, 0&, 500&, AddressOf DoAsync)
blnCallWaiting = False
End Sub

Private Sub StopTimer()
KillTimer 0&, lngTimerId
lngTimerId = 0
blnCallWaiting = False
End Sub

Private Sub DoAsync()
If (blnCallWaiting) Then
StopAsync
g_objOutAddIn.CheckAppointments
End If
End Sub

Public Sub StartAsync()
If lngTimerId <> 0 Then
StopTimer
End If
StartTimer
End Sub

Public Sub StopAsync()
If lngTimerId <> 0 Then
StopTimer
End If
End Sub

Public Sub MakeAsyncCall()
'Set Call Waiting Flag to True
If lngTimerId = 0 Then 'Timer should be running already
MsgBox ("Error: StartAsync before CallAsync ")
blnCallWaiting = False
Else
blnCallWaiting = True
End If
End Sub
 
Back
Top