I have a ComboBox cmb_CxLookup whose row source is
Expand|Select|Wrap|Line Numbers
- SELECT qry_CustMAIN.CustID, qry_CustMAIN.CustName, * FROM qry_CustMAIN ORDER BY qry_CustMAIN.CustName;
My AfterUpdate code is
Expand|Select|Wrap|Line Numbers
- Private Sub cmb_CxLookup_AfterUpdate()
- DoCmd.SearchForRecord acDataForm, "frmMain", acFirst, "[CustID] = " & str(Nz([Screen].[ActiveControl], 0))
- sbfmQuotesRefresh
- End Sub
- sbfm_CustDetails
- lstQuoteSummary
To keep users from accidentally deleting customer information on the frmMAIN, I have locked sbfm_CustDetails 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
Expand|Select|Wrap|Line Numbers
- 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.