Results 1 to 2 of 2
2003-05-15, 15:23 #1
- Join Date
- Jun 2002
- Nottingham, Nottinghamshire, United Kingdom
- Thanked 0 Times in 0 Posts
Dialog form called from several forms (All)
I have developed a dinky dialog form to allow users to select a resident by location, alphbetically, etc. The trouble is I have to have several copies of it with different names relating to the forms with which it is used. It could be called either from the main menu, to allw selection before the main form is opened, or it can be called from the form and returns there with the next selection.
As it currently stands the code in the dialog form checks for the presence of the main form and opens it if not open; then it filters the main form.
What i'd like to do is for the dialog form to be used in all circumstances, but:
1) How do I tell it what form called it so that it can return there?
2) If called from the main menu, how do I tell it what form to go to when finished?
I hope I've explained this sufficiently
2003-05-15, 15:48 #2
- Join Date
- Mar 2002
- Thanked 28 Times in 28 Posts
Re: Dialog form called from several forms (All)
DoCmd.OpenForm has a string argument OpenArgs that you can use to pass information to the form being opened. It is the last argument to OpenForm. You could pass the name of the form to go/return to. The form being opened has a string property OpenArgs that is filled with the OpenArgs argument of DoCmd.OpenForm if available. In my experience, the OpenArgs property may lose its value while the form is open for no discernible reason, so it is best to get it in the On Open or On Load event of the form, and to assign it to a variable.
So, open the dialog like this:
DoCmd.OpenForm FormName:="frmMyDinkyDialog", WindowMode:=acDialog, OpenArgs:="frmFormToReturnTo"
And in the form module of the dialog form:
' Module-level variable
Dim strFormToReturnTo As String
Private Form_Open(Cancel As Integer)
If Not IsNull(Me.Openargs) Then
strFormToReturnTo = Me.OpenArgs
MsgBox "This dialog form is not intended to be opened by itself", vbInformation
Cancel = True