I have two forms (FormA, FormB) with combo boxes (cboA, cboB) that control the record being shown in the subforms (SubformA, SubformB). I have written the following code and attached it to the "AfterUpdate" function on the combo boxes and it updates the subform perfectly.
Private Sub cboA_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[CICustomerID] = " & Str(Nz(Me![cboA], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
Here's my problem....
I have a button on FormA that, when clicked, opens FormB, assigns the value in cboA to cboB and closes FormA. Here's that code:
Private Sub FormA_Button_Click()
Dim combovalue As Double
combovalue = Forms![FormA]![cboA]
DoCmd.Close acForm, " FormA "
DoCmd.OpenForm "FormB", acNormal, "", "", , acNormal
Forms![ FormB]![cboB] = combovalue
End Sub
Unfortunately, I can not figure out how to have SubformB automatically update based on the new value assigned by code to cboB.
I've tried .Requery, "After Update/Change/Dirty/etc." on cboB, "OnOpen" on FormB, and moved the code from cboB "AfterUpdate" to ButtonA "AfterClick" and nothing seems to work.
I need the user to use buttons to navigate through various forms displaying information for the same record. I also need to give the user the option to switch the record using the combo box. Does anyone know how to do this? Is it possible to use code to update the value in a combo box and then have the record in the subform automatically change?
Any help would be greatly appreciated!
Private Sub cboA_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[CICustomerID] = " & Str(Nz(Me![cboA], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
Here's my problem....
I have a button on FormA that, when clicked, opens FormB, assigns the value in cboA to cboB and closes FormA. Here's that code:
Private Sub FormA_Button_Click()
Dim combovalue As Double
combovalue = Forms![FormA]![cboA]
DoCmd.Close acForm, " FormA "
DoCmd.OpenForm "FormB", acNormal, "", "", , acNormal
Forms![ FormB]![cboB] = combovalue
End Sub
Unfortunately, I can not figure out how to have SubformB automatically update based on the new value assigned by code to cboB.
I've tried .Requery, "After Update/Change/Dirty/etc." on cboB, "OnOpen" on FormB, and moved the code from cboB "AfterUpdate" to ButtonA "AfterClick" and nothing seems to work.
I need the user to use buttons to navigate through various forms displaying information for the same record. I also need to give the user the option to switch the record using the combo box. Does anyone know how to do this? Is it possible to use code to update the value in a combo box and then have the record in the subform automatically change?
Any help would be greatly appreciated!
Last edited: