By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,676 Members | 1,636 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,676 IT Pros & Developers. It's quick & easy.

A Timer Event solution

P: n/a
This was an interesting problem. I open a form, CalledForm.

When a record is presented in CalledForm I needed to check the status of
something. If the status is met, I needed to present DialogForm prior
to allowing access to the record in CalledForm. So in the OnCurrent
event of CalledForm I had
If Status Then Docmd.Openform "DialogForm",,,,,acDialog

Worked fine. Later, I was asked to provide a command button in
DialogForm that would call/open "TasksForm" before going back to
CalledForm. This presented a dilemma since "TasksForm" called other
forms as well. And DialogForm was a modal form at this point. That
would mean I'd need to open TasksForm and any other forms it opened as
dialog as well or else they'd be hidden behind DialogForm.

I thought, "No Biggee", I'll set DialogForm's visible status to False
and return control to CalledForm and open the new TasksForm.
If Status then
Docmd.Openform "DialogForm"
If IsLoaded("DialogForm")
Docmd.close "DialogForm"
Docmd.Openform "TasksForm"
Endif
Endif

Didn't work. Why?
OnCurrent->OpenDialogForm->OnCurrent->OpenTaskForm->OnCurrent

This opened TasksForm but control was returned back to the OnCurrent
event of CalledForm and then CalledForm was the current object and
TasksForm was hidden behind it, just like it would have been if I had
called TaskForm from DialogForm.

How I solved it. I modified my last lines of the OnCurrent event to be
'on current event
If Status Then
Me.TimerInterval = 1
End If

By setting the TimerInterval to 1 in the OnCurrent event it permited the
OnCurrent event to complete. A millisecond later and the timer event
would fire.

My code for the Timer was
Private Sub Form_Timer()
Me.TimerInterval = 0 'stop the timer
ProcessSomething
End Sub

You may never need to do something like this. But if you get trapped by
events needing to complete and inhibiting what you want displayed,
this will work like a champ.

Dirty Dancing
http://www.youtube.com/watch?v=Hy1YF54rZZM



Nov 15 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Thu, 15 Nov 2007 07:46:53 -0800, Salad <oi*@vinegar.comwrote:

When you set a modal form's .Visible=False, it will fall out of the
modal loop. That's by design, and can be very handy.

-Tom.
>This was an interesting problem. I open a form, CalledForm.

When a record is presented in CalledForm I needed to check the status of
something. If the status is met, I needed to present DialogForm prior
to allowing access to the record in CalledForm. So in the OnCurrent
event of CalledForm I had
If Status Then Docmd.Openform "DialogForm",,,,,acDialog

Worked fine. Later, I was asked to provide a command button in
DialogForm that would call/open "TasksForm" before going back to
CalledForm. This presented a dilemma since "TasksForm" called other
forms as well. And DialogForm was a modal form at this point. That
would mean I'd need to open TasksForm and any other forms it opened as
dialog as well or else they'd be hidden behind DialogForm.

I thought, "No Biggee", I'll set DialogForm's visible status to False
and return control to CalledForm and open the new TasksForm.
If Status then
Docmd.Openform "DialogForm"
If IsLoaded("DialogForm")
Docmd.close "DialogForm"
Docmd.Openform "TasksForm"
Endif
Endif

Didn't work. Why?
OnCurrent->OpenDialogForm->OnCurrent->OpenTaskForm->OnCurrent

This opened TasksForm but control was returned back to the OnCurrent
event of CalledForm and then CalledForm was the current object and
TasksForm was hidden behind it, just like it would have been if I had
called TaskForm from DialogForm.

How I solved it. I modified my last lines of the OnCurrent event to be
'on current event
If Status Then
Me.TimerInterval = 1
End If

By setting the TimerInterval to 1 in the OnCurrent event it permited the
OnCurrent event to complete. A millisecond later and the timer event
would fire.

My code for the Timer was
Private Sub Form_Timer()
Me.TimerInterval = 0 'stop the timer
ProcessSomething
End Sub

You may never need to do something like this. But if you get trapped by
events needing to complete and inhibiting what you want displayed,
this will work like a champ.

Dirty Dancing
http://www.youtube.com/watch?v=Hy1YF54rZZM

Nov 16 '07 #2

P: n/a
Tom van Stiphout wrote:
On Thu, 15 Nov 2007 07:46:53 -0800, Salad <oi*@vinegar.comwrote:

When you set a modal form's .Visible=False, it will fall out of the
modal loop. That's by design, and can be very handy.

-Tom.
Yes it is.

I did that and opened the new form but the OnCurrent event had not
finished in the original calling form. Thus the new non-modal form
opened but the rest of the OnCurrent event code executed and then the
original calling form became the selected object instead of the form I
had just opened. It was an interesting exercise.
>
>>This was an interesting problem. I open a form, CalledForm.

When a record is presented in CalledForm I needed to check the status of
something. If the status is met, I needed to present DialogForm prior
to allowing access to the record in CalledForm. So in the OnCurrent
event of CalledForm I had
If Status Then Docmd.Openform "DialogForm",,,,,acDialog

Worked fine. Later, I was asked to provide a command button in
DialogForm that would call/open "TasksForm" before going back to
CalledForm. This presented a dilemma since "TasksForm" called other
forms as well. And DialogForm was a modal form at this point. That
would mean I'd need to open TasksForm and any other forms it opened as
dialog as well or else they'd be hidden behind DialogForm.

I thought, "No Biggee", I'll set DialogForm's visible status to False
and return control to CalledForm and open the new TasksForm.
If Status then
Docmd.Openform "DialogForm"
If IsLoaded("DialogForm")
Docmd.close "DialogForm"
Docmd.Openform "TasksForm"
Endif
Endif

Didn't work. Why?
OnCurrent->OpenDialogForm->OnCurrent->OpenTaskForm->OnCurrent

This opened TasksForm but control was returned back to the OnCurrent
event of CalledForm and then CalledForm was the current object and
TasksForm was hidden behind it, just like it would have been if I had
called TaskForm from DialogForm.

How I solved it. I modified my last lines of the OnCurrent event to be
'on current event
If Status Then
Me.TimerInterval = 1
End If

By setting the TimerInterval to 1 in the OnCurrent event it permited the
OnCurrent event to complete. A millisecond later and the timer event
would fire.

My code for the Timer was
Private Sub Form_Timer()
Me.TimerInterval = 0 'stop the timer
ProcessSomething
End Sub

You may never need to do something like this. But if you get trapped by
events needing to complete and inhibiting what you want displayed,
this will work like a champ.

Dirty Dancing
http://www.youtube.com/watch?v=Hy1YF54rZZM

Nov 16 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.