Use the CallByName "Replace" mode window

Source: Internet
Author: User

A modal window can sometimes be handy to use, such as adding a piece of data, popping up a modal window, adding the following code when it's done, and sometimes getting the new added value, such as:

...
Frmclient.show vbmodal
If Increase Success Then
Get new value
End If
...

But if you use an MDI window, it's a hassle, because MDI child forms aren't allowed to display in a modal window, so the above method doesn't work.

So I use CallByName plus a global variable to achieve the above function.

Private Type Selectinfos
Blnaddnewreturn as Boolean ' returns information after it is added
Frmsource as Form ' source Call window
Strfunctionname as String ' The name of the function/procedure to execute when the argument is returned
End Type

Public Guselectinfos as Selectinfos ' information selection

Frminfos

'//Note Be sure to use public, otherwise it cannot be invoked in other windows.
Public Sub Loadclientinfos (ByVal lngid as Long)
' Load Customer information
End Sub

Private Sub AddNew ()
...
With Guselectinfos
. Blnaddnewreturn = True
'//Set source window
Set. Frmsource = Me
'//Set the name of the function to invoke
. Strfunctionname = "Loadclientinfos"
Frmclient.show
End With
...
End Sub

Frmclient

Private Function updateclient ()
...
'***************************************
' * * To determine if it is new when called by another window, and if so, to return the current number
'***************************************
With Guselectinfos
If. Blnaddnewreturn Then
'//Call function return value in Source window
Call CallByName (. Frmsource,. Strfunctionname, Vbmethod, Lngid)
. Blnaddnewreturn = False
End If
End With
'***************************************
...
End Function

The general process is this, although a bit troublesome, but finally is a solution.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.