Lynn_AccessUser
Registered User.
- Local time
- Today, 14:05
- Joined
- Feb 4, 2003
- Messages
- 125
I have a subform where the default view is single form.
On the after update event on my combo boxes I have the following code:
rs = Forms!frmReq!sbfReqItems!txtReqItemID
DoCmd.RunCommand acCmdSaveRecord
Forms!frmReq!sbfReqItems.Requery
Forms!frmReq!sbfReqItems!txtReqItemID.SetFocus
DoCmd.FindRecord rs
When the user changes data in these fields the focus will stay on the current record instead of going back to the first record.
The problem is when the user is adding a new record. There is no value in txtReqItemID (Primary key) because the record has not been saved. As a result, the code breaks because txtReqItemID is null.
If I put in DoCmd.RunCommand acCmdSaveRecord the primary key is created but then it takes me back to the first record instead of staying on the current record.
I can create an if statement to run the rs code when txtReqItemID is not null, but how do I keep the focus on the current record when adding a new record.
Thanks!!!
On the after update event on my combo boxes I have the following code:
rs = Forms!frmReq!sbfReqItems!txtReqItemID
DoCmd.RunCommand acCmdSaveRecord
Forms!frmReq!sbfReqItems.Requery
Forms!frmReq!sbfReqItems!txtReqItemID.SetFocus
DoCmd.FindRecord rs
When the user changes data in these fields the focus will stay on the current record instead of going back to the first record.
The problem is when the user is adding a new record. There is no value in txtReqItemID (Primary key) because the record has not been saved. As a result, the code breaks because txtReqItemID is null.
If I put in DoCmd.RunCommand acCmdSaveRecord the primary key is created but then it takes me back to the first record instead of staying on the current record.
I can create an if statement to run the rs code when txtReqItemID is not null, but how do I keep the focus on the current record when adding a new record.
Thanks!!!