DoCmd for a field refersh

Moxioron

Active Member
Joined
Mar 17, 2008
Messages
436
Office Version
  1. 2019
Hello.

I think this is probably an easy question...

I have a data entry form with several fileds that load into a table. That part works great except when I select the Save command button, I want the form to save and clear the fields.

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , , acMenuVer70

How would I go about doing that? Thanks.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Do you specifically need to save the record?
You could just DoCmd.GoToRecord , , acNewRec


Denis
 
Upvote 0
Yes, I would like the information to save on the table when the 'Save' control button is selected, which works great. But after the data is saved I want the files on the formed zeroed out for the next data entry item.
 
Upvote 0
That should automatically happen - all the fields should be set to their default when you goto a new record.
 
Upvote 0
When I select the command button, it does populate the table fine, but doesn't zero out the fields for the next entry. The previous record information still remains....
 
Upvote 0
So how are you going to a new record?

If you aren't you need to add code like Denis posted to move to a new record.
 
Upvote 0
1. You should NOT use DoMenuItem code. That is old legacy code which isn't all that informative as to what it is doing. Use the DoCmd.RunCommand code instead.

2. If you are using any unbound controls then you would need to clear them in code but it depends on what you are doing with your form as to when and how you would need to do this.
 
Upvote 0
My assumption is that the form is bound since you are doing a save record.

To clear the form you need to navigate to a new (blank) record. This will automatically clear all the bound controls on the form.

Your save button could use soemtihg like thia:

Code:
' Save the record 
If Me.Dirty = True then Me.Dirty = False
 
' go to a new blank record
 DoCmd.GoToRecord , , acNewRec
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,283
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top