The mode window is sometimes very convenient. For example, when adding a piece of information, pop up a mode window, continue to perform the following code, sometimes used to achieve new value, such as:
... frmclient.show vbmodalif Increase the success of the new value end if ...
However, if you use the MDI window, you will be troubles, because the MDI child form is not allowed to be displayed in the mode window, so the above method will not pass.
So I use CallByName to add a global variable to implement the above functions.
Private Type SelectInfos blnAddNewReturn As Boolean 'whether to increase after the return information frmSource As Form' source window strFunctionName As String used to call 'when the function to be executed when the return parameter / procedure name End TypePublic guSelectInfos As SelectInfos' information when selecting
FRMINFOS
'// Note Be sure to use public, otherwise you cannot call in other windows. Public Sub LoadClientInfos (ByVal lngId as Long) 'load customer information End SubPrivate Sub AddNew () ... With guSelectInfos .blnAddNewReturn = True' // Set the source window Set .frmSource = Me '// set the name of the function to call .strFunctionName = "LoadClientInfos" frmclient.show end with ... End SubfrmClient
Private function updateclient () ... '*************************************************** * * Judging whether the new increase is when the other window is called, if it is necessary to return the current number '****************************** ********* With guSelectInfos If .blnAddNewReturn Then '// call the function return value in the source window call CallByName (.frmSource, .strFunctionName, vbMethod, lngID) .blnAddNewReturn = False End If End With' ** ********************************************* ... End Function
This is like this, although it is a bit trouble, but it is also a solution.