How do I hide a column in a table using VB code.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I hide an Access 2003 column in a table using VB code. I can see how
to do it from the datasheet view but how do I do it using code.
 
hi Steve,
How do I hide an Access 2003 column in a table using VB code. I can see how
to do it from the datasheet view but how do I do it using code.
Use a form in datasheet view and set the ColumnHidden property of the
controls to False.


mfG
--> stefan <--
 
Stefan thanks for the reply but...

Let me explain further what I am trying to do.

I am creating a table on the fly which can contain from 1 to 20 columns. I
am then using a macro to sent the table to a file (or whatever). The problem
is it always sends the first column which is the autonumber column which I do
not want.
If I go in manualy to the datasheets and use the pull down to hide the
column it works fine but because I am re-creating the table each time using
code ,the hide column is not kept. Hence my desire to do it via VB code.

Any further suggestions will be much apresiated.

Thanks
Steve
 
hi Steve,
I am creating a table on the fly which can contain from 1 to 20 columns. I
am then using a macro to sent the table to a file (or whatever). The problem
is it always sends the first column which is the autonumber column which I do
not want.
Hence my desire to do it via VB code.
Okay. You also need to create a query on the fly to export instead of
your table. I assume you know the fieldname of your ID field (untested):

Dim Count As Long
Dim dbc As DAO.Database
Dim Statement As String
Dim tdf As DAO.TableDef

Set dbc = CurrentDb
Set tdf = dbc.TableDefs.Item("YourTable")

Statement = ""
For Count = 0 To tdf.Fields.Count - 1
If tdf.Fields.Item(Count).Name <> "IDFIELDNAME" Then
Statement = Statement & ", " & tdf.Fields.Item(Count)
End If
Next Count
Statement = "SELECT " & Right(Statement, Len(Statement) - 2) & _
"FROM yourTable"

dbc.CreateQueryDef AName, Statement


mfG
--> stefan <--
 
Back
Top