Results 1 to 4 of 4
  1. #1
    GeorgeJ is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    67

    How to activate an open form from another form

    I have 2 non-modal forms open, Form1 and Form2. They are overlapping but not completely. When Form2 is the active form, some of Form1 is visible on the left and when Form1 is active some of Form2 is visible on the right. So if Form2 is active and I want to switch to Form1 I just move the cursor over to the area of the screen where Form1 is showing and click. Similarly for activating Form2 when Form1 is active.

    Eventually I want to have both forms occupy the entire screen and have buttons on each allowing the other to be activated. On Form2 I have a button, Command4, which has the following click code

    Private Sub Command4_Click()
    Forms!Form1.Activate


    End Sub

    When both forms are open I activate Form2 and I click Command4 I get the following error message

    Runtime error 2465

    Application defined or object defined error


    Any suggestions as to what the correct code might be?


    Thanks in advance

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    From Help: "You can make a form active by opening it, clicking it or a control on it, or by using the SetFocus method in Visual Basic."

    Try:
    Code:
    Private Sub Command4_Click()
    Forms!Form1.SetFocus
    End Sub

  3. #3
    GeorgeJ is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    67
    That seems to work.

    Thank you

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You're welcome....

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 8
    Last Post: 05-22-2014, 10:19 PM
  2. Replies: 1
    Last Post: 03-02-2014, 01:31 PM
  3. Replies: 2
    Last Post: 04-01-2013, 04:23 PM
  4. Replies: 1
    Last Post: 05-03-2012, 02:25 PM
  5. Replies: 2
    Last Post: 02-26-2010, 08:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums