cmd Button on pg1 of Tab Control to open pg2 of Tab Control to same record (1 Viewer)

coasterman

Registered User.
Local time
Today, 02:42
Joined
Oct 1, 2012
Messages
47
I have a frmMain with a Tab Ctl named 'NavCtl'

pg1 of my Tab Control is a continuous form and PK field is 'MasterIssID' and I would like to open the single form 'frmIssueDetails' display of that same record on pg2

I'm confused as I've read the docCmd.OpenForm is not the right method when dealing with Tab Control? but I currently

Thanks
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:42
Joined
Oct 29, 2018
Messages
14,049
Hi. I am guessing both pages 1 and 2 of your tab control has a subform in it, correct? If so, you can easily show the same record in the second page by simply adding an unbound textbox on the main form to display the current PK value of the subform in page one. Then, you can use that textbox as a Linked Master Field for your single form subform on page two.
 

coasterman

Registered User.
Local time
Today, 02:42
Joined
Oct 1, 2012
Messages
47
Yes I did actually try that before but its causing me an issue for some reason. I have another page on the control which is linked to the single form already so I think it may be causing a conflict? I know when I try to add the child field name it appears and then a split second later vanishes.

I have double checked the txt box name on the child form and it is correct and I also have my txtMasterID displaying the MasterID on the continuous form.

I could probably benefit anyway from the VBA option as I think I will also need to do something similar between some popup forms where I then need to open other pages to a specific record. But if for no other reason than its been driving me nuts these past few hours so it would be great to know the answer.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:42
Joined
Oct 29, 2018
Messages
14,049
So, is the single view subform linked to the main form? If not, then you can use VBA. However, if it's linked, you might consider posting a sample copy of your db to make sure we don't send you down the wrong path.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 04:42
Joined
Feb 28, 2001
Messages
19,023
To start, all pages of a tab-controlled form are part of the same form and therefore have the same recordsource and are at the same record. What you describe involves sub-forms, each of which must be separately synchronized to the main if that is the goal. Since pg 1 of your tab control is a continuous form, my question is about what you want to see on pg 2.

By the way, "I've read the docCmd.OpenForm is not the right method when dealing with Tab Control" - both true and false. The question here is, what are you trying to open? If it is a tab, it is already open, just might not be visible. If it is a sub-form, then as long as it is properly linked with the main form, you really shouldn't HAVE to open it. But if there is a REALLY late binding of the sub-form control, it is possible to use it, I suppose.
 

arnelgp

error reading drive A:
Local time
Today, 18:42
Joined
May 7, 2009
Messages
11,461
you don't use DoCmd.OpenForm.

drag the Single Form to the 2nd Page of the tab control (just make sure the 2nd page is selected before dragging your form).

1. add an Unbound Textbox (txtID) on the Main Form (not inside the Tab ctrl).
set it's Visible property to No.
set its Control Source:

=[theContinuousFormNameOnPage1]![MasterIssID]


2. on the second subform (on Pg 2),
click on the Border of the subform (make sure a Yellow-Orange rectangle is around the subform).
on its Property Sheet->Data:

Link Master Fields: [txtID]
Link Child Fields: [MasterIssID]
 

coasterman

Registered User.
Local time
Today, 02:42
Joined
Oct 1, 2012
Messages
47
Hi – thanks for all the previous suggestions. Have been looking at them again now I’m had some time to re-visit this

The presumption that the two views I am trying to navigate and sync between is exactly my scenario.


The 2 sub forms in question are on a Tab control which is on a main form which I am using simply a container for the Tab control and buttons for navigating between the various subforms on the pages of the Tab Control (page tabs hidden). For clarity my main from is not an Access Navigation from. I realise having no recordsource in the main from may be having some bearing on my issue but it was a simple logistical issue in that the screen real estate was at a premium (homeworkers on ancient laptops!) so having all the forms on a tab control seemed at the time a reasonable workaround.


For ease I’ll refer to the two pages on the Tab control as pg1 and pg 2

Mainfrm = ‘frmMain’

The main Tab Control name ‘NavCtl’ (I believe this is never referenced but included it just in case)

On pg1 - control name ‘ImportCTL’ - ( The name of the continuous form in the control ‘sfrmImport’ and having txtMasterIssue_FK)

On pg2 - control name ‘MasterIssueCTL’ (The name of the single view form in the control ‘sfrmMasterIssue’ and having txtMasterIssue. Field name in table isMasterIssueID )

Neither of these sforms in the controls are late binding


Desired behaviour - when user selects a record (command button on each record) in the sfrmImport it takes them to pg2 containing the relevant record sfmMaster . By now each record in sfrmImport has a FK to the masterIssue table


I did the Master/child setup with unbound txtfield on frmMain to sync another of the pages but its not working in the case of the subforms on pg1 and pg2 and I cant fathom out why.


Is there another method of syncing these two pages without too much complexity? My VBA level is pretty basic so if that comes into play please assume I’m a novice!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:42
Joined
Oct 29, 2018
Messages
14,049
Hi. If you can't apply the suggestion we gave you, then perhaps consider posting a sample copy of your db, so we can show you how to do it. It will also help us understand your situation better.
 

coasterman

Registered User.
Local time
Today, 02:42
Joined
Oct 1, 2012
Messages
47
Apologies if my explanation wasn't very clear - anyway hopefully the attachment will illustrate better than I was able to

I did break it quite a few times stripping some tables a modules out so its about a bare as can be and still represent the issue I'm having. The two subforms are the 1st two buttons on the menu 'Excel Source' and 'Master Issues' . Hopefully my notations on the cmdBtn and the forms will make sense.

P.S there are a pair of cascading combo boxes on the Master Issue form, the 2nd combo box isn't retaining its value when you select another value for combo box 1 in another record. If it makes for better organisation I'll happily post separately but as I was uploading the DB anyway I thought I'd take a small liberty
 

Attachments

  • Stripped - Copy (6).zip
    381.7 KB · Views: 2

theDBguy

I’m here to help
Staff member
Local time
Today, 02:42
Joined
Oct 29, 2018
Messages
14,049
Hi. Thanks for posting a copy of your db. I just quickly tried to implement the suggestion we gave you earlier. Please let us know if this doesn't do what you wanted.
 

Attachments

  • Stripped - Copy (6).zip
    380.4 KB · Views: 2

coasterman

Registered User.
Local time
Today, 02:42
Joined
Oct 1, 2012
Messages
47
Thanks DBguy - thats what I was looking for wasn't it. Entirely my fault in that I realise now what I wanted wasn't actually what I needed.

When moving from the continuous form to the related record in the single form I still needed access to all records. I have found a way to drop the Master and CHild link by means of a cmdButton on the single form and then reset them if ever a user needs to navigate from the continuous back to the single form and have posted the example on this post.

I wonder what your view is on that method and if there is a more elegant way of achieving the same thing. I am sort of aware of pointers in recordsets and I am trying to learn where I can - would this be the sort of scenario where a recordset comes into its own?
 

Users who are viewing this thread

Top Bottom