Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Call main form cmd from Sub (A2K)

    I have a sub form with a text field on it called

  2. #2
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Call main form cmd from Sub (A2K)

    One way to do this: Take the code that opens other form when you click command button and place it in a separate sub procedure in main form, call it something like "OpenOtherForm" or something meaningful. Declare sub as Public. Command button's OnClick event will now look like:.
    <pre>Private Sub cmdSeeJobs_Click()
    OpenOtherForm
    End Sub</pre>


    For subform's textbox double-click event use something like:
    <pre>Private Sub txtJobJobID_DblClick(Cancel As Integer)
    Dim frm As Form
    Set frm = Me.Parent.Form
    frm.OpenOtherForm
    Set frm = Nothing
    End Sub</pre>

    The OpenOtherForm sub needs to be declared as Public to be able to call it from subform as shown in this example. If declared Private error will occur.
    HTH

  3. #3
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Call main form cmd from Sub (A2K)

    A little different from Mark:
    Create in the main form a Function
    Function OpenForm
    MyCommandButton_Click
    End Function

    In the on Doubleclick of the subform field :
    Private Sub Myfield_DblClick(Cancel As Integer)
    Me.Parent.OpenForm
    End Sub
    Francois

  4. #4
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Call main form cmd from Sub (A2K)

    Thanks Mark,

    I did what you suggested with one small change, I made the

  5. #5
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Call main form cmd from Sub (A2K)

    And now I

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •