synchronize subforms

Nirious

Registered User.
Local time
Today, 10:57
Joined
Jul 31, 2004
Messages
106
I have a form, which has two tabs on it. On each tab, there is a page with a subform. Both subforms are based on the same table. The main form(with the tabs)is not linked to a table.
Now what I want is that when I am on the first subfom( on tab1) and I am on say record 6, that when I now go to the second tab with subform2, that I'm there on the same record as on subform1 (so also record 6)

And it should also work viceversa

Any id how to get this done?
 
Can you post a sample of your database?
Would it work if you were to have the main form linked to your table and not use subforms. Just put the controls you want straight onto your main form?
 
I have kinda messed around abit

And have solved my problem like this,maybe it can helpsomeone with a similar problem:

I have used my tablekey (PLUnr) to synchronize the two subforms.

I first made a textfield (txtRecordHouder)on the main form (Artikels) to act as a global variable.
Than I put the following code in the OnCurrent event of both subforms (ArtikelsEen and Artikelstwee):

Code:
Form_Artikels.txtRecordHouder.Value = Me.PLUnr.Value

After that I put this code in the tabs control OnChange event.

Code:
Private Sub TabCtl0_Change()
If TabCtl0.Value = 0 Then
    If Not IsNull(Form_Artikels.txtRecordHouder) Then
        Dim rs As Object
        Set rs = Form_ArtikelsEen.Recordset.Clone
        rs.FindFirst "[PLUnr] = " & Form_Artikels.txtRecordHouder
        If Not rs.EOF Then Form_ArtikelsEen.Bookmark = rs.Bookmark
    End If
ElseIf TabCtl0.Value = 1 Then
    If Not IsNull(Form_Artikels.txtRecordHouder) Then
        Dim rst As Object
        Set rst = Form_Artikelstwee.Recordset.Clone
        rst.FindFirst "[PLUnr] = " & Form_Artikels.txtRecordHouder
        If Not rst.EOF Then Form_Artikelstwee.Bookmark = rst.Bookmark
    End If
End If
End Sub

I don't know if its the best solution, but it works.

Nirious
 
Last edited:
I couldn't link the table to the main form without the subforms, because I needed to show a form view on the first tab and a datagrid on the second one.

If you know some improvements on my code, plz feel free to adjust it
Greets,
Nirious
 

Users who are viewing this thread

Back
Top Bottom