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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sync Record Pointer across tabs/subforms

Status
Not open for further replies.

vlingen

Programmer
Aug 4, 2006
31
US
Hi -

I have a form with 3 tabs. Each tab has a subform. Each subform is based on different queries that all pull from table "A".

I'm looking for a way to synchronize the record pointers across the three tabs and do it without filtering the data.

Example: If the user clicks on the 1st tab and moves to record 10. Then clicks on the second tab, I want it to show all the data of the query, but have the record pointer be on the same Primary Key match of the 1st tab.

Any ideas? - Thanks
 
It should be possible to use the recordset in the current event of each subform:

Me.sfrmControl2.Form.Recordset.FindFirst "ID=" & Me.ID
<..>
Me.sfrmControln.Form.Recordset.FindFirst "ID=" & Me.ID

You may need to use the recordsetclone and bookmarks.



 
Maybe you could store the position of the "record pointer" in a global variable. If you go to the second tab, you can use that value in something as docmd.findrecord to go that record (id)...


Pampers [afro]
Keeping it simple can be complicated
 
I'm making progress on my own issue.

I've set up a field on the parent form which I update on the On Current of each subform. I fill it with the Primary Key# of the common table.

Now I need to find out how to do a "Find" from the tab for this Key. (VBA) When I launch the "find" I will be on the Tab On Change and not on the subform.

thanks...
 
I tried this:

Me.SALENTRY1.RecordsetClone.FindFirst "SalentryID =" & me.sid
Me.Page2.RecordsetClone.FindFirst "SalentryID = " & me.sid
Me.Page3.RecordsetClone.FindFirst "SalentryID = " & me.sid


but get an error - Method or data member not found. I also get this error as a "Recordset
 
Maybe set focus on the subform if tab2 is selected then use Find or Docmd.findrecord...

Pampers [afro]
Keeping it simple can be complicated
 
The problem is in the referencing of the subforms, as far as I can see:

Me.[Name of Subform Control].Form.Recordset
 
also notice that Remous uses the recordset not the recordsetclone. If you move in the clone it will not affect the movement of the subforms recordset.
 
No matter what I can't get past the error - Method or data member not found.

I tried:

Me.SALENTRY1.SetFocus
Me.SALENTRY1.Recordset.FindFirst "SalentryID =" & nid
Me.Page2.SetFocus
Me.Page2.Recordset.FindFirst "SalentryID = " & nid
Me.Page3.SetFocus
Me.Page3.Recordset.FindFirst "SalentryID = " & nid


and

Me.SALENTRY1.Form.Recordset.FindFirst "SalentryID =" & nid
Me.Page2.Form.Recordset.FindFirst "SalentryID = " & nid
Me.Page3.Form.Recordset.FindFirst "SalentryID = " & nid


When the error occurs it highlights "Recordset".

Any other ideas? (also thanks for all the suggestions!)
 
Hi All -

Thanks for your help.

Here is the code that finally worked. (I had the subform name wrong)

Dim nid As String
nid = Me.SID
If Me.TabCtl0.Value = 0 Then
Me.SALENTRY1.SetFocus
Me.SALENTRY1.Form.Recordset.FindFirst "SalentryID =" & nid
End If

If Me.TabCtl0.Value = 1 Then
Me.SubdivisionSub.SetFocus
Me.SubdivisionSub.Form.Recordset.FindFirst "SalentryID = " & nid
End If

If Me.TabCtl0.Value = 2 Then
Me.VacantSub.SetFocus
Me.VacantSub.Form.Recordset.FindFirst "SalentryID = " & nid
End If
 
There is no need to set focus. It could even lead to problems.
 
The setfocus was for the docmd.find (and indeed can give easily errors). Dont need that for Remou's FindFirst on a recordset - so that is a better solution.

Pampers [afro]
Keeping it simple can be complicated
 
How are ya vlingen . . .

I believe your initial problem was due to [blue]sequence of initialization of the subforms[/blue] when the mainform is open. Have a look at my post in the following thread, bearing in mind that subforms on any particular level open in a particular order. If a subform down the line is'nt open yet and you seek access . . . an error is raised!

thread702-1464334

Just bear in mind errors caused by the above . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top