Bookmarking

  • Thread starter Thread starter Question Boy
  • Start date Start date
Q

Question Boy

Hi,

I am trying to setup a subform double-click event on a textbox to set the
focus on one of the main form's tabs forms and then goto a specific
recordset. Here is what I have but which is not working.

NumChng = Me.[ChgNum]
'Move focus to the appropriate control
Me.Parent.[118-Changements Main].SetFocus
'Retrieve the proper recordset
Set rs = Me.Recordset.Clone
rs.FindFirst "[118-20_Numéro du changement] = " & NumChng
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Set rs = Nothing

It pull the proper 'NumChng' value, and then does set the focus on the
tab/subform but I can not pull up the corresponding recordset. Can anyone
see my error?!

Thank you

QB
 
Question Boy said:
Hi,

I am trying to setup a subform double-click event on a textbox to set the
focus on one of the main form's tabs forms and then goto a specific
recordset. Here is what I have but which is not working.

NumChng = Me.[ChgNum]
'Move focus to the appropriate control
Me.Parent.[118-Changements Main].SetFocus
'Retrieve the proper recordset
Set rs = Me.Recordset.Clone
rs.FindFirst "[118-20_Numéro du changement] = " & NumChng
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Set rs = Nothing

It pull the proper 'NumChng' value, and then does set the focus on the
tab/subform but I can not pull up the corresponding recordset. Can anyone
see my error?!


If this code is running on the subform, then your use of Me is incorrect in
these lines:
Set rs = Me.Recordset.Clone
rs.FindFirst "[118-20_Numéro du changement] = " & NumChng
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

If it's the main form that you want to reposition to the record matching
NumChng, then do this:

With Me.Parent
Set rs = .RecordsetClone
rs.FindFirst "[118-20_Numéro du changement] = " & NumChng
If Not rs.EOF Then .Bookmark = rs.Bookmark
End With

Note: I also replaced "Recordset.Clone" with "RecordsetClone", which will be
more efficient if this code is running in a MDB or ACCDB, not an ADP.

It occurs to me that [118-Changements Main] may be a subform, and it may be
that it is that subform you want to reposition. If that's the case, the
above code won't work. Please post back if that is so.
 
Back
Top