• Dialog form called from several forms (All)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Dialog form called from several forms (All)

    • This topic has 1 reply, 2 voices, and was last updated 22 years ago.
    Author
    Topic
    #387587

    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

    Viewing 0 reply threads
    Author
    Replies
    • #676869

      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
      Else
      MsgBox “This dialog form is not intended to be opened by itself”, vbInformation
      Cancel = True
      End If
      End Sub

    Viewing 0 reply threads
    Reply To: Dialog form called from several forms (All)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: