Solved

Subform will not open within the main form

Posted on 2016-08-02
3
51 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
3 Comments
 
LVL 49

Accepted Solution

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

/gustav
0
 
LVL 35

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

840 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