I have a form A with a datasheet subform with multiple columns, plus a button "Change my column". The user can select the columns he/she wants to see via a popup from form A. After closing popup, I want to refresh the datasheet to show new show/hide columns.
I open the form by fteching the current column hide settings and using subform.control.columnhidd
en = usersetting for each field/column.
This works well.
User then selects 'change my columns' and ticks/unticks each column heading. This is the code behind the button.
Private Sub cmdDisplaySetting_Click()
DoCmd.OpenForm "frmSearch_Project_Fields", , , , , acDialog
It calls a routine ShowHideColumns which does exactly what you would expect. For each datasheet column it sets .columnhidden. This works well for hiding previously shown columns, but not exactly right for previously hidden columns that are now shown.
For a column that was previously hidden and is now shown it shows the column heading correctly and the column width is correct, but it does not show the data
correcly. Instead I get the #Name?
shown in every row for that field. If you close form and reopen (where it now knows that column is not hidden) all is good.
The datasheet is a bound form to the main table with all the fields.
I thought requerying the subform might fix it but I still get the error.
So, if a bound datasheet field was HIDDEN on open, and then you change it to not HIDDEN, the columns appears correctly but it does not know about the column values.
Any ideas how to get the value to refresh?