Hiding fields on a form

DKM

Registered User.
Local time
Today, 12:02
Joined
Feb 24, 2007
Messages
24
This one is annoying me now.

I am trying to work out hiding a column on the opening of a new form but cant seem to get the VBA side working the way i need it to. The scenario is:

I have one form open (in datasheet view), within one of the fields (field2) on this field i have an ON ENTER event set to open a second form (this form is based on a query that uses a field from the initial form as its filter. So when i Click on field 2 it filters form 2 based on the data in field 1). The second form opens is Singleform view. I can get the second form to open and filter the way i want to but i also want to hide specific fields.

At present this is the code im using

DoCmd.OpenForm "Form2", acNormal, , , acFormEdit, acWindowNormal
DoCmd.Requery
Forms!Form2!Field2.ColumnHidden = True
DoCmd.SelectObject acForm, "Form1"

the requery is required so when i move to a new line it updates the filter and the select object is to reselect form1 after all the other actions are complete.

I have also tried doing it with the column.visable = true/ false code but this doesnt hide the field.

Any help is appreciated on this.
 
I think you might be confusing the terms "column" or "field" with "control". Form controls display fields and columns, so using the .ColumnHidden property would not work. It WOULD work for, say, a multi-column combo box. If you want to hide a field / column, then set the visibility of the control that displays that data to false...
Code:
Forms!Form2!Field2.Visible = False
 
Your explanation is, to be honest, a real muddle, primarily because of the lack of use of real form/field names, instead using field2, etc. It's hard to be sure whether there is one
"field 2" or a "field 2" on both forms. But if I understand your problem correctly, you're trying to get Field2 on your second (just opened) form to be invisible. To do this you're using

Forms!Form2!Field2.ColumnHidden = True

but according to you post, Form2 is a Single View form. ColumnHide is only valid on forms presented in Datasheet View! You should, I think, be using

Forms!Form2!Field2.Visible = False

Sorry, Adam, I got interupted mid-reply and didn't see you there. As I said, ColumnHide does apply to forms as well, but only in Datasheet View.
 

Users who are viewing this thread

Back
Top Bottom