By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,436 Members | 2,958 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,436 IT Pros & Developers. It's quick & easy.

Manual split form as a subform

Seth Schrock
Expert 2.5K+
P: 2,941
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
Expand|Select|Wrap|Line Numbers
  1. 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.
Expand|Select|Wrap|Line Numbers
  1. 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.
Apr 2 '13 #1
Share this Question
Share on Google+
6 Replies

Expert Mod 5K+
P: 5,397
Seth, you've lost me a tad here:
Do you have:





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.
Apr 4 '13 #2

Seth Schrock
Expert 2.5K+
P: 2,941
Second set if tables. When I Chang records in subform 1, I want it to go to the same record in subform 2.
Apr 4 '13 #3

Seth Schrock
Expert 2.5K+
P: 2,941
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.
Expand|Select|Wrap|Line Numbers
  1. Public Sub MoveRecord(NewRecord As Long, Stage As Integer, CurrentFormType As String)
  2. On Error GoTo Error_Handler
  4. Select Case Stage
  5.     Case 1
  6.         Select Case CurrentFormType
  7.             Case "CF"
  8.                 Forms!frmDecisionTreeWizard!frmDT_Stage1_SF.Form.Recordset.FindFirst "LevelID = " & NewRecord
  10.             Case "SF"
  11.                 Forms!frmDecisionTreeWizard!frmDT_Stage1_CF.Form.Recordset.FindFirst "LevelID = " & NewRecord
  13.         End Select
  15.    Case 2
  17. End Select
  19. Exit_Procedure:
  21.     Exit Sub
  23. Error_Handler:
  24.     Call ErrorMessage(Err.Number, Err.Description, "modDecisionTreeWizard: MoveRecord")
  25.     Resume Exit_Procedure
  26.     Resume
  28. End Sub
I then call it with the following code
Expand|Select|Wrap|Line Numbers
  1. 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.
Apr 7 '13 #4

Expert Mod 5K+
P: 5,397
Expand|Select|Wrap|Line Numbers
  1. '<removed some code here>
  2.    '
  3.    Dim zsrs As DAO.Recordset
  4.     '<removed some code here>
  5.     '
  6.     'setup to restrict events.
  7.     Set zsrs = Me!sfm_qry_asset_inventory_logbook.Form.Recordset
  8.     zsrs.MoveLast
Forces my subform to move to the last record in the default sort order.
Apr 9 '13 #5

Seth Schrock
Expert 2.5K+
P: 2,941
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
Expand|Select|Wrap|Line Numbers
  1. intFlag = 1
  2. DoCmd.OpenForm...
  3. 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.
Apr 13 '13 #6

Seth Schrock
Expert 2.5K+
P: 2,941
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.
Apr 13 '13 #7

Post your reply

Sign in to post your reply or Sign up for a free account.