Solved

Subform will not open within the main form

Posted on 2016-08-02
3
59 Views
Last Modified: 2016-08-03
I have two sub-forms on a main form.   The 2nd subform is set to visible = false when the main form opens.  But on 1st subform, when the user clicks a command button in the 1st subform I want the 2nd subform to become visible within the main form.  But with the onclick code I have currently the 2nd subform, named "subfrmSearchContractsDS",  is opening outside the main form and I cannot figure out why.

Here is my onclick code:

    Dim strWhereCondition As String

    'several lines of code here for the strWhereCondition

    DoCmd.OpenForm "subfrmSearchContractsDS", acFormDS, , strWhereCondition, acFormReadOnly, acHidden
    
    Forms!subfrmSearchContractsDS.Visible = True

Open in new window

0
Comment
Question by:SteveL13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 50

Accepted Solution

by:
Gustav Brock earned 250 total points
ID: 41739227
Don't call DoCmd.OpenForm.
Only make the subform Visible.

/gustav
0
 
LVL 37

Assisted Solution

by:PatHartman
PatHartman earned 125 total points
ID: 41739245
Me.subfrmSearchContractsDS.Visible = True
0
 
LVL 31

Assisted Solution

by:Helen_Feddema
Helen_Feddema earned 125 total points
ID: 41739424
Make sure that you use the name of the Subform control in the line that makes it visible, not the form name itself (they should be different).  For example, the subform might be named fsubSelectedData and the Subform control name subSelectedData.  Also, you might want to place the button to make the 2nd subform visible on the main form, at least if you ever want to see it when the 1st subform is invisible.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question