Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Forms for ONE Record 1

Status
Not open for further replies.

Lightning

Technical User
Jun 24, 2000
1,140
AU
Hi All
I have a form consisting of a Tab control with 4 tabs. Each tab has a subform control displaying one page of a multi-page form. I need to synchronise each page of the form so that when I tab from page to page, each page displays the same record.

I have the form working correctly for existing records. I can open the form, select any existing record and view it across the 4 tabs with no problem. I can use the navigation buttons to move to any other existing record and the forms will correctly display that record. So far, no problem.

However, if I add a new record, the forms will not synchronise. I add a new record, select a primary key value from a combo box list and use the after update event to save/requery the form. But the other forms will not synchronise until after I close the form and re-open.

Can anyone suggest a way to synchronise the new record across the 4 tabs?

************************************************
This is the code to save/requery the new record

Code:
Private Sub Office_AfterUpdate()
Dim lngRecordNum As Long
    lngRecordNum = Me.CurrentRecord
    Me.Requery
    DoCmd.GoToRecord , , acGoTo, lngRecordNum
    Call Form_Current
End Sub

*************************************************
This code passes the PK value from the subform to the parent form

Code:
Private Sub Form_Current()
    strCond = Office
'Set the textbox txtOffice to the Office value
    Parent.SetFocus
    Parent.txtOffice = strCond
End Sub

***********************************************
This code passes the PK value to the next subform to synchronise the record.

Code:
Private Sub subfrmControlledAccessOffice_Enter()
    Call pgeOffice_Click
    Me!subfrmStateOffice!Office.SetFocus
    If Me!subfrmStateOffice!Office = &quot;<<Select from Droplist>>&quot; Then
        Exit Sub
    Else
        DoCmd.FindRecord txtOffice, , , acSearchAll, , acCurrent
    End If
    
End Sub
***************************************************
I'm obviously missing something in the After update code, but what?

Any suggestions would be greatly appreciated!

TIA

Lightning

 
Using 4 subform controls is your problem, and it seems clumsy to me. You might consider using a single subform directly on the main form, and replacing the tab control with an option group containing 4 option buttons. Clicking a button causes the subform to execute a GoToPage method.

It wouldn't look quite identical, but it would surely solve your sync problem.

If using a real tab control is important to you, cut one of the subforms to the clipboard, then paste it outside the tab control. This breaks the connection between the tab control and its visibility. Then drag the subform back over the tab control so it looks like it's in the tab pages; the actual pages are empty. You can use the tab's Change event to execute the GoToPage method of the subform. Rick Sprague
 
Rick

Thanks for your help. I used your second suggestion and I now have the form working correctly.

Thanks again.

Lightning
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top