Hide a datasheet column (1 Viewer)

mdray00

Registered User.
Local time
Today, 01:27
Joined
Jul 29, 2009
Messages
18
Hi guys,

This has been driving me crazy.

I have a query that runs and the results come up in a datasheet.

Now there are times where certain criteria are met when I need certain columns to be hidden.

I cannot for the life of me figure out how to do it. I seem to have tried everything.

U know when u select the column click format and then hide. I just need the code to do the same as that.

So I state the name of the cloumn and then hide it.

Can any1 help me.

Thanks
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 10:27
Joined
Jan 20, 2009
Messages
12,851
Display the results of the query in a form or report. This provides a lot more configurability. Queries are really just meant for getting answers, not displaying the results.

Try putting the form in datasheet mode and use vba to switch the controls' Visible property to true or false.
 

mdray00

Registered User.
Local time
Today, 01:27
Joined
Jul 29, 2009
Messages
18
The things is that they want the resuts to look like an excel sheet. So it needs to be a datasheet view. I tried using a datasheet form but this only 1 record at a time.
 

HAMMAMABUARQOUB

Registered User.
Local time
Today, 03:27
Joined
Jul 29, 2009
Messages
75
I think this can be done by this code for example you wan to show Fld2 and hide Fld1

Code:
Fld2.Properties("ColumnHidden") = True
Fld1.Properties("ColumnHidden") = False
but exactly how in the Query.. i really didn't try.. but I will, cos codes can be only written on forms and its better to have a form with a query in it...
HAMMAM
 

MarkK

bit cruncher
Local time
Yesterday, 17:27
Joined
Mar 17, 2004
Messages
8,179
If all you have is a query then remove the field from the SELECT clause, or as Hammam notes, you can set the ColumnHidden property of a field on a form, but you can reference it directly also...
Code:
Me.SomeField.ColumnHidden = True
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 10:27
Joined
Jan 20, 2009
Messages
12,851
The things is that they want the resuts to look like an excel sheet. So it needs to be a datasheet view. I tried using a datasheet form but this only 1 record at a time.

This sounds like your form is still in Single Form view. If the query is set as the Record Source of the form and the view property to DataSheet it should show all the records in the query.

Otherwise perhaps the form has a filter set to Filter On Load or is a subform with a Parent/Child link from the main form.
 

Users who are viewing this thread

Top Bottom