Hiding a Column

David44Coder

Member
Local time
Tomorrow, 01:39
Joined
May 20, 2022
Messages
137
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.
 
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.
 
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
 
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:
ColumnHidden =True only works with datasheet forms. Visible =False works with any type of form
 
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

Back
Top Bottom