Gustav Brock
gustav at cactus.dk
Tue Jun 10 10:28:49 CDT 2014
Hi Tom You have reached one of the dark corners of Access. Problem is that no event is raised when saving a datasheet view and no method is present to "save" the form if not in design view. Changes to a Datasheet view is considered a user action not relevant for the developer. The simplest solution for your case, I believe, would be to replace the command button with a tab control with two pages, one for each subform. Then the user can switch back and forth as he/she likes using the tabs, and everything should be saved when closing the form. /gustav -----Oprindelig meddelelse----- Fra: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] På vegne af ewaldt at gdls.com Sendt: 10. juni 2014 16:41 Til: accessd at databaseadvisors.com Emne: [AccessD] Saving subform format I have a form (frmTreeView), that includes a subform. The subform has two possible source objects, each being a form within the application (sfrmTable1, and sfrmData); these are switched by the user via a command button. sfrmTable1 is a simple datasheet view of a query. If sfrmTable1 is the current source object for the subform, the user can move columns around, make the visible or invisible, size them, etc. If the user then closes the parent form (with sfrmTable1 still showing), a pop-up asks if he/she wants to save the format of sfrmTable1. If the user responds in the affirmative, sfrmTable1 is saved as it was reformatted, and it will appear that way next time. If, however, the user does not close the form but uses the command button to switch the subform's source object to sfrmData, then the formatting is lost. When the parent form is closed, the pop-up will again be displayed, but it's meaningless; the formatting has already been lost, and the user will only be saving the form in the format it already had. OK, sorry - long intro. What I want to happen is simply that the user's changes are saved automatically, without his/her ever being asked. No pop-ups, and no lost formatting. Is there a way to do this? I've tried saving sfrmTable1 (have to open it separately, and it does not reflect the new formatting anyway), using SendKeys (because ctrl+S works sometimes; doesn't seem to be consistent, though). Any other ideas? If there's some code to use, I could simply place it in the code behind the command button Thanks for reading this lengthy cry for help, and thanks in advance for any help you can give me. Tom Ewald Mass Properties General Dynamics Land Systems