Results 1 to 2 of 2
  1. #1
    pncbiz is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Jul 2020
    Location
    Maryland
    Posts
    66

    Setting continuous form to a specific record FROM ANOTHER SUBFORM

    Hi - I have a two subforms on an unbound main form. I use a textbox on the mainform to synchronize the two. The first subform is a continuous form to pick which order you want to edit; the second subform is where you edit the data for the order.

    When the user changes the order total (quantity or unit cost) in the second subform, I want it to update the first subform. Easy enough: In the AfterUpdate, I save the record and requery the first subform. The problem is that when the first subform requeries, it resets the pointer to the first record in the sort, making the second subform also change to that record. I don't want that. I want the first subform to requery, then return to the record it was on before the requery.

    I've tried several different ways, but here's the latest iteration. It is in the AfterUpdate property of a textbox on the second subform. Be gentle....I am a novice trying to use my google-fu to solve problems...

    Code:
      Dim rst As DAO.Recordset
      Dim varBookmark As Variant
      
      Set rst = Me.Parent.subOrderSearch.Form.RecordsetClone
      varBookmark = rst.Bookmark
      Me.Parent.subOrderSearch.Form.Requery
      rst.Bookmark = varBookmark
    Thanks,
    Phil

  2. #2
    pncbiz is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Jul 2020
    Location
    Maryland
    Posts
    66
    Solved it! My google-fu came through!
    Code:
      Dim lngPK As Long
    
      lngPK = Me.OrderID
    
    
      Me.Parent.subOrderSearch.Form.Requery
      With Me.Parent.subOrderSearch.Form.RecordsetClone
        .FindFirst "OrderID = " & lngPK
        If .NoMatch Then
          MsgBox "Record not found!", vbCritical
        Else
          Me.Parent.subOrderSearch.Form.Bookmark = .Bookmark
        End If
      End With

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 06-24-2019, 11:20 AM
  2. Replies: 17
    Last Post: 02-28-2017, 02:12 PM
  3. Replies: 9
    Last Post: 11-21-2014, 07:06 PM
  4. Replies: 29
    Last Post: 01-29-2014, 01:04 PM
  5. Replies: 2
    Last Post: 09-12-2011, 11:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums