requery a comboBox at main form from subfrm then return back to the Subfrm Control (1 Viewer)

GeneH

New member
Local time
Today, 11:30
Joined
Jun 6, 2019
Messages
3
Hello,
I am trying to requery a control on a main form from an AfterUpdate event of a control on a subform and then return back to the record and control at the subform. Instead i am returned to the first record of the subform.
When i debug, it seems correct, the record i want does show correct at the findfirst statement. but at the form the first record is returned.

Any help would be greatly appreciated.

Here is my current code

Private Sub cboVersionType_AfterUpdate()

Me.Refresh

Dim Version As Long

'set variable to current record ID
Version = Me.VersionID

Forms![frm3EstStep1].Form![cboVersionSearch].Requery 'Main form combobox

'return form to original record on the subform
With Me.RecordsetClone
.fi "VersionID= " & Version
If .NoMatch Then 'incase another current user deletes the record
MsgBox "Record not found!", vbCritical
Else 'go to that record on the subform
Me.Bookmark = .Bookmark
End If
End With


If CurrentProject.AllForms("frm4EstTypes").IsLoaded Then
DoCmd.Close acForm, "frm4EstTypes"
End If

End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 11:30
Joined
Oct 29, 2018
Messages
21,545
Hi. Probably not going to make any difference for now but try using Requery instead of Refresh.
 

Micron

AWF VIP
Local time
Today, 14:30
Joined
Oct 20, 2018
Messages
3,478
pretty sure when you requery the main, you are also going to requery the sub whether you like it or not - as long as the sub is bound. I've read that to solve this you'll have to clone the sub recordset, set its bookmark, requery the main then go back to the bookmarked record. Never done it so can't offer any code examples.
 

Users who are viewing this thread

Top Bottom