Using ColumnHidden Properties in Datasheet Objects

I have an MS Access form with Datasheet subforms .
Using the code, I change the ColumnHidden property of the various columns. But when I close the form, they ask me whether to save the Datasheet table table table.

  • How can I stop the form to constantly ask the user about the same table layout?
  • I have no choice but to change the Datasheet to a regular subform?
+4
source share
2 answers

If you always hide the same columns, create a query that has only the columns that you want to display, and use this as the source of your subform.

If you still need hidden fields (child keys, etc.), you will need to create a regular form. It's not so bad:

  • just install it on your desk,
  • drag and drop columns into the form (formatting and placement don't matter)
  • set it as a data table
  • edit labels (they become column headings)
  • change the order of the tabs (this controls the display order of the columns)
  • view the table and hide the columns you need.
  • keep fit
  • add this form as a subform to the main form
+2
source

I'm not sure there is an easy way to do this, because Access saves a lot of properties using forms. If you have not used the Datasheet view, you can hide the CLOSE button on the form and replace it with the command button to close the form using this code:

DoCmd.Close acForm, Me.Name, acSaveNo 

But since this is a description, you cannot do it.

You might try to embed your datasheet as a subform in an unrelated parent form, but I don't know if using the code above the command button in the parent form or not preserving the width of the columns in the inline subform.

One solution would be to reinitialize the column width in the OnLoad event of your document. Then you can open the form with acHidden and set the column width to their correct values ​​in the OnLoad event (you need to multiply 1440 inches to get the twips value to assign the column width properties), as well as the end of OnLoad, set Me.Hidden to False.

But it really is a bit of a pain in the butt.

I am afraid this is one of the drawbacks of using data tables, as there is no way to define a close button that will not save the end user UI data.

0
source

All Articles