Question Tab control goto subform record (1 Viewer)

exASHacto

Registered User.
Local time
Today, 12:36
Joined
Feb 20, 2012
Messages
25
Hi all,

I have a tab control with 11 pages (departments). Each page have 3 subforms (country, channel, product). Each page can have multiple countries, channels and products.

Example:
Marketing: Country A, Country B and Country C
Country A: Channel A and Channel B
Channel A: Product A, Product B and Product C

So a combination can be:
Marketing in Country A in Channel A with Product A.

I enter several informations (sales, dates, comments etc) on each subform. The subforms are linked (master/child). I store the different primary keys in hidden textboxes.


When I navigate between the pages, the selection resets due to a necessary requery. How can I keep the selection?

THANKS!
 

mdlueck

Sr. Application Developer
Local time
Today, 06:36
Joined
Jun 23, 2011
Messages
2,631
When I navigate between the pages, the selection resets due to a necessary requery. How can I keep the selection?

You would need to invent some VBA code to relocate the previous control selection.

In my applications, when returning to a Multiple Records Form, I relocat the previously selected record based on knowing the ID of that previously selected record. I chose to display the autonumber ID column in the UI. I remember the ID in a VBA variable, and when returning, if not 0 then I relocate the previously selected record. My code to look up the previously selected record is as follows:

Code:
  Dim daoRS As DAO.Recordset

  'Locate the record if we received a valid ID
  If intRecordID > 0 Then
    Set daoRS = Me.RecordsetClone
    daoRS.FindFirst ("[id] = " & intRecordID)
    'If we could find the newly added record, jump to it
    If Not daoRS.NoMatch Then
      Me.Bookmark = daoRS.Bookmark
    End If
  End If

  'Clean up the connection to the database
  Set daoRS = Nothing
Oh, and when the multiple records form is in a subform control, I use this code on the subform...

Code:
  Dim daoRS As DAO.Recordset

  'Locate the record if we received a valid ID
  If lngRecordID > 0 Then
    Set daoRS = Me.RecordsetClone
    daoRS.FindFirst ("[id] = " & lngRecordID)
    'If we could find the newly added record, jump to it
    If Not daoRS.NoMatch Then
      Me.Bookmark = daoRS.Bookmark
[B]      'As this form is used within a subform control, necessary to setfocus
      'to the subform control first, then the control itself which is on the subform form
      Me.Parent.subform_quality.SetFocus
      Me.fldid.SetFocus
[/B]    End If
  End If

  'Clean up the connection to the database
  Set daoRS = Nothing
 
Last edited:

exASHacto

Registered User.
Local time
Today, 12:36
Joined
Feb 20, 2012
Messages
25
Thank you for your time.

In the tbl_ctrl change event I store the auto numbers before I requery. The autonumbers shows the selection in the subforms.

I guess I need to use your code in a specific order. First set the country auto number, then the channel and last the product...
 

Users who are viewing this thread

Top Bottom