A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

programmatically hiding fields in a datasheet form



 
 
Thread Tools Display Modes
  #1  
Old August 19th, 2006, 08:01 PM posted to microsoft.public.access.forms
@.
external usenet poster
 
Posts: 1
Default 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  
Old August 19th, 2006, 09:53 PM posted to microsoft.public.access.forms
Brendan Reynolds
external usenet poster
 
Posts: 1,241
Default 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  
Old August 19th, 2006, 09:59 PM posted to microsoft.public.access.forms
John Nurick
external usenet poster
 
Posts: 492
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:10 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.