By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,913 Members | 1,228 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,913 IT Pros & Developers. It's quick & easy.

default code for Save button

P: 11

I've created a form that has 7 subforms. It is the same subform, bound to a table, just repeated. This form represents a week, and each subform is used to enter in data for each day of the week. The main form has a combo box that must have a value selected before anything else can happen. Once that value is selected, the 7 subforms are enabled, and also one of the fields is populated with the value from the main form. These subforms also have a combo box with a default value, and a text box with a default value, along with the field from the main form.

My main form has a save button, which I created just using the button wizard and default code. It also has a Close button, also created with the wizard.

My issue is that when I use the save button, if none of the subforms have been changed from the default values, none of them get saved. If a default value is changed, then that record corresponding to that subform is saved, but the others arent.

My Close button saves each of the subforms and their records, even if the defaults have not been changed.

Is that a part of the Save button that Access creates, that it will only save updated things? When the main form populates each of the subforms, they all create new entries in the table, the primary key is autonumber, so they are different records, but they dont get saved unless the default values are changed... and I'm not sure why

Oct 11 '07 #1
Share this Question
Share on Google+
4 Replies

Expert 2.5K+
P: 3,072
Why don't you insert all seven rows when the weeknumber is determined or e.g. in the OnOpen event of the form. Just check there are no rows for that week and INSERT them.

Oct 11 '07 #2

P: 11
thanks for the suggestion

The primary key for the table with subforms is based on the day and an employeeID. The day is autopopulated, but the employeeID is not set in the form until the user chooses which one. So I dont think it could be inserted without the rest of the key identified...of course I could be wrong about that.

Oct 15 '07 #3

Expert 2.5K+
P: 3,072
So you'll need to use the combo's AfterUpdate event to insert the seven rows when not yet present.
So effectively the user is updating these rows instead of creating new records.
The "cost" is however that you'll have to DELETE the rows when the user presses the [Cancel] button.

Clear ?

Oct 15 '07 #4

P: 11
oh, yea that makes sense.

thanks for your help on this
Oct 15 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.