Controlling Columns in Datasheet View

N

Neil Ginsberg

Is there a way to control which columns the user displays in Datasheet view?
I have certain fields hidden, and I want to prevent the user from being able
to display them by going to Unhide Columns.

Is there any event that is triggered when the columns in Datasheet view are
changed, or is there some other way to control which columns are displayed
in Datasheet view? I'm using Access 2003.

Thanks!
 
S

Stuart McCall

Neil Ginsberg said:
Is there a way to control which columns the user displays in Datasheet
view? I have certain fields hidden, and I want to prevent the user from
being able to display them by going to Unhide Columns.

Is there any event that is triggered when the columns in Datasheet view
are changed, or is there some other way to control which columns are
displayed in Datasheet view? I'm using Access 2003.

Thanks!

By far the easiest way is to make a custom commandbar which mimicks the
datasheet commandbar in all but the unhide option, then use that as your
form's commandbar.

Hint: Create a commandbar and Ctrl-drag items from the datasheet bar onto
yours till you've got everything you want, then remove the unhide option.
 
A

Allen Browne

Simplest way is to create a query that delivers only the fields you want.
Then there is nothing for the user to unhide.

If that's not suitable, perhaps Continuous View would suit, rather than
Datasheet View.
 
T

tina

well, you can set the control's Width property to zero in Design view, then
add code to the form's MouseUp event to set the control's ColumnHidden
property to True. you'll need to add a custom menu that does *not* have the
Unhide Columns option, or just remove the menu bar entirely.

hth
 
N

Neil Ginsberg

Thanks. This may be an impossible task. The users need Unhide Columns,
because they like to change the fields that are displayed. I suppose I could
give them a custom Unhide Columns dialog box, listing only the columns I
want them to be able to use. That may be the only solution.

Would be nice if there was a Form_ColumnsChanged event that could manage it,
or (better), under control properties, where it says Display When: instead
of Screen and Print, have Screen, Print, Form View only, and Datasheet View
only. That would be nice; but it isn't.

Thanks.
 
N

Neil Ginsberg

The users want Unhide Columns, as they change the fields that are displayed.
I could, I suppose, create a custom Unhide Columns function. That seems to
be the only way.
 
M

Marshall Barton

Neil said:
Is there a way to control which columns the user displays in Datasheet view?
I have certain fields hidden, and I want to prevent the user from being able
to display them by going to Unhide Columns.

Is there any event that is triggered when the columns in Datasheet view are
changed, or is there some other way to control which columns are displayed
in Datasheet view? I'm using Access 2003.


You might find something useful here:
http://www.lebans.com/autocolumnwidth.htm
 
S

Stuart McCall

Neil Ginsberg said:
The users want Unhide Columns, as they change the fields that are
displayed. I could, I suppose, create a custom Unhide Columns function.
That seems to be the only way.

If you do create such a function, you should be aware of the fact that a
column which is the default width (1 inch) and hasn't been altered since the
form was opened will have a ColumnWidth value of -1. So when you loop over
the Columns collection to fill your listbox, combo etc it's worth bearing
that in mind (IOW <1 or >0 are not the comparisons to use).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top