X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
   Reply to this topicStart new topic
> Subform Does Not Get Displayed - Shows Blank Space, Access 2016    
post May 28 2020, 02:41 AM

Posts: 89
Joined: 19-February 20
From: Mumbai, India

Form 1: A Continuous List form to display list of Projects (frmProjList). There are buttons on this form to either Add a New Project OR View an Existing Project

Form 2: A Main Form(frmProjPlan) to display Project Details using a SubForm container(sfmProjPlan).
This form has just a title info in the header and a subform container fully covering the details section.
The On Open event of Form 2 defines SourceObject of SubForm Container = SubForm 1
SubForm 1: (frmProjPlanSummary) - displays Summary data of a Project
SubForm 2: (frmProjPlanTasks) - a continuous form to display Tasks under the project

When "Add New Project" button is clicked on Form 1, It opens Form 2 - BUT DISPLAYS BLANK SPACE in place of the SubForm.
HOWEVER, It does add a new record in the ProjList table. I can see that a new blanlk line is added in Form 1.

Below are the pieces of Code involved

'When I step thru - this is how the code is getting executed
' 1. SUB 1 runs
' 2. on this line DoCmd.OpenForm "frmProjPlan" - it moves to SUB 3
' 3. In SUB 3 due to the check I am performing in first line using ComingFrom string, it exits SUB3 and execution moves to SUB 2
' 4. here on this line:  Me.sfmProjPlan.SourceObject = "frmProjPlanSummary"  - the execution moves to SUB 3 and completes SUB 3
' 5. Then it hits the End Sub line of SUB 2 and eventually End Sub line of SUB 1

'SUB 1: Button to Add a New Project on frmProjList (Form 1)
Private Sub btnNewProj_Click()
    OpnMode = "ADD"
    ComingFrom = "frmProjList"        'using this in OnOpen of frmProjPlanSummary to bypass the code there when that code is executed before running OnOpen of frmProjPlan
    DoCmd.OpenForm "frmProjPlan"
End Sub

'Next Logical flow of code should be the SUB 2, i.e. OnOpen event of frmProjPlan. But that doesn't happen, Instead the code moves to SUB 3 - OnOpen of subform frmProjPlanSummary.

    'SUB 2 : OnOpen event of frmProjPlan
Private Sub Form_Open(Cancel As Integer)
    If OpnMode = "View" Then Me.cmbProjID = Nz(Me.OpenArgs)
    Me.tbMainCurrDate = Date - Weekday(Date, conFirstDay) + 1
    ComingFrom = "frmProjPlan"
    Me.sfmProjPlan.SourceObject = "frmProjPlanSummary"
End Sub

    'SUB 3 : This code gets executed immly after the DoCmd.OpenForm "frmProjPlan" line in the SUB 1 above.
    'OnOpen event of frmProjPlanSummary
Private Sub Form_Open(Cancel As Integer)
    If ComingFrom = "frmProjList" Then Exit Sub
    If OpnMode = "ADD" Then
        Me.AllowAdditions = True
        Me.AllowEdits = True
        DoCmd.RunCommand acCmdRecordsGoToNew
        Me.ProjStatus = "OPEN"
    ElseIf OpnMode = "VIEW" Then
        Me.AllowEdits = False
        Me.RecordSource = "SELECT ProjList.* FROM ProjList " _
                        & "WHERE (((ProjList.ProjID)=[Forms]![frmProjPlan]![cmbProjID]));"
    End If
    OpnMode = ""
End Sub    'After this code runs the program then moves to SUB 2

Sub MakeEditable()
    Dim Ctrl As Control
    Me.AllowEdits = True
    Me.AllowAdditions = False
    For Each Ctrl In Detail.Controls
        If Ctrl.Tag <> "NA" Then
            Debug.Print Ctrl.Name
            If TypeOf Ctrl Is TextBox Then
                Ctrl.Enabled = True
                Ctrl.Locked = False
            ElseIf TypeOf Ctrl Is ComboBox Then
                Ctrl.Enabled = True
                Ctrl.Locked = False
            End If
        End If

    If OpnMode = "" Then Me.Client.SetFocus
    Me.btnEdit.Visible = False
    Me.btnSave.Visible = True

End Sub

Any idea what's happening here? It used to work very well earlier. Not sure what went wrong.
This post has been edited by hemant: May 28 2020, 02:53 AM
Attached File(s)
Attached File  Blank_New_Proj_form_error.jpg ( 215.27K )Number of downloads: 5
Go to the top of the page
post May 28 2020, 01:39 PM

Posts: 1,533
Joined: 25-January 16
From: The Great Land

That's a lot of code to wade through.

Have you step debugged?

If you want to provide db for analysis, follow instructions at bottom of my post.

Attachments Manager is below the edit post window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Go to the top of the page

Custom Search

RSSSearch   Top   Lo-Fi    13th July 2020 - 07:20 AM