Combo Boxes to remember values

paulcraigdainty

Registered User.
Local time
Today, 16:21
Joined
Sep 25, 2004
Messages
74
I have three combo boxes (name, team and activity) and a text box (comments)on my form. When the user has selected their name, team and activity and then entered relevant comments they click save this then saves the record to the table. I have used the following statements as on click events behind the save buttonoCmd.RunCommand acCmdSaveRecord and DoCmd.GoToRecord , , acNewRec

Currently this saves the record to the table and resets the form so the user can enter another activity. I don't want the name and team combo boxes to reset. I want them to retain the value from what was last entered, can someone help me with the additional VBA. Thanks
 
Add 2 unbound text boxes to your form and make them non-visible (txtBox1, txtBox2 as sample names). These 2 text boxes can be used to store the current values in the combo boxes before the record is saved and then restore the values to the combo boxes after the new record is opened.

In the code for your command button:

Me.txtBox1 = Me.cboName
Me.txtBox2 = Me.cboTeam
DoCmd.RunCommand acCmdSaveRecord
DoCmd.GoToRecord , , acNewRec
Me.cboName = Me.txtBox1
Me.cboTeam = Me.txtBox2

Note that cboName and cboTeam need to be replaced with the actual names of your combo boxes.

Hope this works for you.
 

Users who are viewing this thread

Back
Top Bottom