If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
programmatically hiding fields in a datasheet form
I have a subform in datasheet view with field "x" on it... and on some
event I can hide or unhide it... like this. Me.Table1_subform.Form("x").ColumnHidden = False But, I can't see a way to get a collection of the field names from the record source (table) it is bound to! I want to loop through all the fields and hide or unhide based on their names! ??????????? Any ideas? Thanks in advance |
#2
|
|||
|
|||
programmatically hiding fields in a datasheet form
Here's something I posted recently in response to a similar question. This
sets the ColumnWidth property, but you should be able to modify it to your needs. Change the line 'ctl.ColumnWidth = -1' to something like ... If ctl.Name = "Whatever" Then ctl.ColumnHidden = True End If Private Sub Form_Load() Dim frm As Form Dim ctl As Control Set frm = Me.sfrTest.Form For Each ctl In frm.Controls If ctl.ControlType = acTextBox Then ctl.ColumnWidth = -1 End If Next ctl End Sub -- Brendan Reynolds Access MVP @. wrote in message ... I have a subform in datasheet view with field "x" on it... and on some event I can hide or unhide it... like this. Me.Table1_subform.Form("x").ColumnHidden = False But, I can't see a way to get a collection of the field names from the record source (table) it is bound to! I want to loop through all the fields and hide or unhide based on their names! ??????????? Any ideas? Thanks in advance |
#3
|
|||
|
|||
programmatically hiding fields in a datasheet form
You can get the field names by iterating Form.Recordset.Fields or
Form.RecordsetClone.Fields. But you'll need to keep a clear head if your controls have the same names as the fields they are bound to. It's probably a good idea to use explicit syntax throughout, e.g. Me.Table1_subform.Form.Controls("x").ColumnHidden to avoid confusion between the control called x and the field called x. On Sat, 19 Aug 2006 19:01:45 GMT, @. wrote: I have a subform in datasheet view with field "x" on it... and on some event I can hide or unhide it... like this. Me.Table1_subform.Form("x").ColumnHidden = False But, I can't see a way to get a collection of the field names from the record source (table) it is bound to! I want to loop through all the fields and hide or unhide based on their names! ??????????? Any ideas? Thanks in advance -- John Nurick [Microsoft Access MVP] Please respond in the newgroup and not by email. |
Thread Tools | |
Display Modes | |
|
|