Hiding a Column (1 Viewer)

David44Coder

Member
Local time
Tomorrow, 01:26
Joined
May 20, 2022
Messages
109
I wonder if this is possible?
Code:
DoCmd.OpenForm "frmMain", acFormDS, , WhereClause


    With Forms![frmMain]
        .OrderBy = "[MyID], [iCost]"
        .Hide [A Column called iTemp] <<<<<<<<<<<<<<<<
        .OrderByOn = True
        .ShortcutMenu = False
    End With

There is no .Hide but perhaps called something else?
Other that that I found
Set fld = dbs.TableDefs!Products.Fields!ProductID
fld.Properties("ColumnHidden") = True
But not sure how to use that in my With-End With block.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 08:26
Joined
Feb 28, 2001
Messages
27,149
In Access, you can't REALLY hide a column in a form, but you can make it have .Width = 0. Just as good unless you wanted to keep the column header but not the column's data.
 

David44Coder

Member
Local time
Tomorrow, 01:26
Joined
May 20, 2022
Messages
109
Thanks Doc_Man That would be fine as the header isn't needed. But having some difficulty getting it to work, although no errors are reported, it just stays the same width.
Code:
DoCmd.OpenForm "frmMain", acFormDS, , WhereClause
With Forms![frmMain]
        .OrderBy = "[MyID], [iCost]"
        .Controls("iTemp").Width = 0
        .OrderByOn = True
        .ShortcutMenu = False
    End With
 

isladogs

MVP / VIP
Local time
Today, 14:26
Joined
Jan 14, 2017
Messages
18,211
You can hide a column in a datasheet form.
Put code like this in the Form_Load event
Code:
Me.ControlName.ColumnHidden=True

Or if you want to use a With...End With block

Code:
Private Sub Form_Load()
With Me
    .ControlName.ColumnHidden = True
End With
End Sub
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 14:26
Joined
Jan 14, 2017
Messages
18,211
ColumnHidden =True only works with datasheet forms. Visible =False works with any type of form
 

David44Coder

Member
Local time
Tomorrow, 01:26
Joined
May 20, 2022
Messages
109
Thank you Colin, that worked treat. First in Form Load, then in my existing With-End With block which calls the Form and where the column is wanted hidden (conditionally).
I had actually almost got there, but when the controlName did not appear in the dropdown, assumed it was a dead end.
 

Users who are viewing this thread

Top Bottom