Ok, sorry folks, but I simply can't wrap my head around this no matter how much I research
I have a ComboBox cmb_CxLookup whose row source is
The Bound column is 1 CustID, which is hidden from the user
My AfterUpdate code is
This works perfectly on my main form frmMAIN (record Source is qry_CustMAIN) which has 2 subforms that display with the correct customer information once the selection has been made from ComboBox cmb_CxLookup
- sbfm_CustDetail s
- lstQuoteSummary
To keep users from accidentally deleting customer information on the frmMAIN, I have locked sbfm_CustDetail s and users must open frmCustMAIN (record Source is also qry_CustMAIN) from one of 2 buttons New Customer or Edit Customer. Edit works fine, but when I add a new customer (new CustID created) and close the form I'm stalling out.
My OnClose event is below
When the form closes and the focus returns to frmMAIN the customer is indeed selected in the cmb_CxLookup as expected, but I still need to click to get the AfterUpdate code to run for the new company to display in the subforms. Is there any way to automate this?
Any help, as always is greatly appreciated.
I have a ComboBox cmb_CxLookup whose row source is
Code:
SELECT qry_CustMAIN.CustID, qry_CustMAIN.CustName, * FROM qry_CustMAIN ORDER BY qry_CustMAIN.CustName;
My AfterUpdate code is
Code:
Private Sub cmb_CxLookup_AfterUpdate() DoCmd.SearchForRecord acDataForm, "frmMain", acFirst, "[CustID] = " & str(Nz([Screen].[ActiveControl], 0)) sbfmQuotesRefresh End Sub
- sbfm_CustDetail s
- lstQuoteSummary
To keep users from accidentally deleting customer information on the frmMAIN, I have locked sbfm_CustDetail s and users must open frmCustMAIN (record Source is also qry_CustMAIN) from one of 2 buttons New Customer or Edit Customer. Edit works fine, but when I add a new customer (new CustID created) and close the form I'm stalling out.
My OnClose event is below
Code:
Private Sub Form_Close() 'Requery the Main Customer List DoCmd.OpenQuery "qry_CustMAIN" DoCmd.Requery 'the record shows at this stage DoCmd.Close 'Requery Customer List and set value to new record Forms![frmMAIN].Requery Forms![frmMAIN].cmb_CxLookup.Requery Forms![frmMAIN].cmb_CxLookup.Value = Me.CustID Forms![frmMAIN].cmb_CxLookup.setFocus End Sub
Any help, as always is greatly appreciated.
Comment