Manual split form as a subform

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    Manual split form as a subform

    I'm aware that true split forms can't be set as subforms and retain the split form functionality. What I'm trying to do is use two subforms to act like a split form. My main problem is that I want the moving between records in one to be mirrored in the other, preferably working both ways. I had initially tried
    Code:
    Me.Parent!frmDT_Stage1_SF.Form.FindFirst "LevelID = " & Me!LevelID
    I got an error number 2465 - "You Entered an expression that has an invalid reference to the property |. The property may not exist or may not apply to the object you specified." Thinking that it was because there wasn't a control linked to the field LevelID in the other subform, I added it and made it invisible and then ran my code again. The error changed to number 2455 - "Microsoft Access can't find the field '|1" referred to in your expression. You may have misspelled the field name, or the field may have been renamed or deleted." I then tried the following code and got the same error.
    Code:
    Me.Parent!frmDT_Stage1_SF.Form.Recordset.FindFirst "LevelID = ID & Me!LevelID
    There has to be a way to do this, but I can't think of what to try.
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    Seth, you've lost me a tad here:
    Do you have:
    form_parent
    subform_child_1

    Or

    form_parent
    subform_child_1
    subform_child_2

    Or

    form_parent
    subform_child_1
    subform_to_chil d_1_child_2

    or what?

    Your code looks like the first set of forms I gave; however, your question seems to point to the second set of forms listed.

    Comment

    • Seth Schrock
      Recognized Expert Specialist
      • Dec 2010
      • 2965

      #3
      Second set if tables. When I Chang records in subform 1, I want it to go to the same record in subform 2.

      Comment

      • Seth Schrock
        Recognized Expert Specialist
        • Dec 2010
        • 2965

        #4
        Back working on this again. Here is what I have tried now. I setup a sub that would work for multiple forms and then just pass it the information that it needs. My idea was to get out of having to reference the subform through the parent form.
        Code:
        Public Sub MoveRecord(NewRecord As Long, Stage As Integer, CurrentFormType As String)
        On Error GoTo Error_Handler
        
        Select Case Stage
            Case 1
                Select Case CurrentFormType
                    Case "CF"
                        Forms!frmDecisionTreeWizard!frmDT_Stage1_SF.Form.Recordset.FindFirst "LevelID = " & NewRecord
                    
                    Case "SF"
                        Forms!frmDecisionTreeWizard!frmDT_Stage1_CF.Form.Recordset.FindFirst "LevelID = " & NewRecord
                
                End Select
                
           Case 2
           
        End Select
        
        Exit_Procedure:
        
            Exit Sub
        
        Error_Handler:
            Call ErrorMessage(Err.Number, Err.Description, "modDecisionTreeWizard: MoveRecord")
            Resume Exit_Procedure
            Resume
        
        End Sub
        I then call it with the following code
        Code:
        MoveRecord Me!LevelID, 1, "CF"
        I'm getting the following error on line 8: Error Number 2455 - You entered an expression that has an invalid reference to the property Form/Report.

        I'm not sure what is wrong with the reference.

        Comment

        • zmbd
          Recognized Expert Moderator Expert
          • Mar 2012
          • 5501

          #5
          Code:
          '<removed some code here>
             '
             Dim zsrs As DAO.Recordset
              '<removed some code here>
              '
              'setup to restrict events.
              Set zsrs = Me!sfm_qry_asset_inventory_logbook.Form.Recordset
              zsrs.MoveLast
          Forces my subform to move to the last record in the default sort order.
          Last edited by zmbd; Apr 9 '13, 12:12 PM. Reason: [z{finished a partial thought}]

          Comment

          • Seth Schrock
            Recognized Expert Specialist
            • Dec 2010
            • 2965

            #6
            Finally! I have figured out what was staring at me in the face. I was getting the error when I was loading the form. Because I have two subforms on the same main form and I have put the same code in each subform's OnCurrent event. What is happening is that the one subform is being loaded before the second. Thus when subform 1's OnCurrent event is running, subform 2 hasn't loaded yet and thus there is no Form inside the subform control. If I comment out the record move, open the form, and then uncomment the record move, it works perfectly. Now I need to come up with a way to keep my code from running when the form is opened, but still allow it to run when I'm changing records. Here are my ideas that I'm going to try:
            1. Setup a global variable to act like a flag when opening the form, something like this
            Code:
            intFlag = 1
            DoCmd.OpenForm...
            intFlag = 0
            I could then test for the flag value in the forms' OnCurrent events.

            2. I had an idea, but then I realized that it wouldn't work, so I guess I only have one idea so far.

            If you think you have a better solution, please let me know. The main form will only be opened from one button and that button only. I will have at least one other set of subforms paired together like this on a different tab on the same main form, so I would need the solution to work for multiple connected sets of subforms.

            Sorry it took me so long to get back with you on this Z. I'm only able to work on this database at work while I'm not on the clock because my mouse at home is about broke and designing a database with it requires about 10 undo clicks per change attempted :(. So I'm limited to weekends to work on this database.

            Comment

            • Seth Schrock
              Recognized Expert Specialist
              • Dec 2010
              • 2965

              #7
              My solution in idea 1 does work, so I can move on to work on my next problem, but I'm still open to ideas if there is a better way to do this.

              Comment

              Working...