What event to use when you return to a form ?

PNGBill

Win10 Office Pro 2016
Local time
Tomorrow, 00:13
Joined
Jul 15, 2008
Messages
2,271
Hi Forum, 2010 accdb.
I have form with a command button that starts a function.

The function may require another form to open and when finished, you return to the original form and click the command button for the function to restart from where it was stopped - all works fine.

What I would like is that you don't need to click the button again.
I think this code should do it
Code:
If TempVars!CalcLateFees = "BulkLateFees" Then
        'restart fncBulkLateFees
        fncBulkLateFees
    Else
        'do nothing
    End If
But I can't get it to fire.
Tried GotFocus and Activate but appears to not "fire"

Also tried this code on the closing form
Code:
If TempVars!CalcLateFees = "BulkLateFees" Then
        fncBulkLateFees
        DoCmd.Close
    Else
        DoCmd.Close
    End If
Thought here is the function will start and the form will close leaving the original form open but again, doesn't appear to work.:confused:

Appreciate any advice:)
 
If you open the form as dialog it will pause the code in the procedure that called it until it closes. So you could open the form from the first form and set it to be acDialog for the WindowMode:= and then you can have the close of the first form just after that code. When the second form closes then it will run that close code.
 
Hi Bob, There are some optionial jobs to do when going down the 2nd form track which became difficult with dialog mode hence I setup the TempVars to keep track of the situation and avoid the function from starting at the beginning of the recordset when and if we eventually get back to it.

Just wanted to avoid a few "clicks" as there can be quite a few instances of branching off.
 
What Bob is saying is:
Code:
Code 1
If SomeCondition = True Then
    Docmd.OpenForm "FormName",acNormal, , , ,[COLOR=Red][B]acDialog[/B][/COLOR]
End If
Code 2
So Code 2 will not run until the form is closed. If the condition was not met then the form will not open and Code 2 will automatically run.
 
Thanks again Bob and vbaInet,

I had a typo - should be TempVars!CalcLateFee - without the "s":o

The function checks to see if a Late Fee is Due and most of the time it would be charged but on a few occiasions we may need to check out some historical data that could require a few different forms and even reposts to be used to confirm a Late Fee should be charged.

I thought with Dialog you can only use the form that is opened and not have the option to go off somewhere and return ?

While typing this, I did get one of my Events to do the job (now the typo is fixed), not sure which :confused: but will grab a few MsgBox's and find out.
 
i general do this

docmd.openform "someform"

while isopen("someform")
doevents
wend

this pauses execution in the way you want, but leaves the popup form sizeable, and the rest of your app working normally

now there is no isopen function, so I use this one, which can also be used to wait for other objects, such as reports to close, as well as forms.

Function IsOpen(strName As String, Optional objtype As Integer = acForm)
IsOpen = (SysCmd(acSysCmdGetObjectState, objtype, strName) <> 0)
End Function
 

Users who are viewing this thread

Back
Top Bottom