Solved Can I Hide Empty Fields in Search Form ? (1 Viewer)

Local time
Today, 16:13
Joined
Oct 31, 2021
Messages
42
Hello Everyone,
Can i hide empty fields in search form
Example if s/f 2,34,5,6 ( empty not contain any data ) ?


1637134430845.png




1637134104716.png
 
Local time
Today, 16:13
Joined
Oct 31, 2021
Messages
42
Can hide entire columns.

Looks like a non-normalized structure.
thank you for your reply
can you send me the code to try it with many thanks
 

June7

AWF VIP
Local time
Today, 07:13
Joined
Mar 9, 2014
Messages
5,488
Form in datasheet view, use ColumnHidden property.

Me.[S/F 2].ColumnHidden = True

Strongly advise not to use spaces nor punctuation/special characters in naming convention.
 

June7

AWF VIP
Local time
Today, 07:13
Joined
Mar 9, 2014
Messages
5,488
Or since it appears the datasheet is a subform and if code is in main form:

Me.subformcontainername.Form.[S/F 2].ColumnHidden = True
 

Gasman

Enthusiastic Amateur
Local time
Today, 16:13
Joined
Sep 21, 2011
Messages
14,364
I can see the next question coming :)

"How do I determine that the column is empty?"
 
Local time
Today, 16:13
Joined
Oct 31, 2021
Messages
42
Or since it appears the datasheet is a subform and if code is in main form:

Me.subformcontainername.Form.[S/F 2].ColumnHidden = True
i try to but below code in on current subform
i dont know how do Form in datasheet view, use ColumnHidden property.

Me.subview.Form.[S/F 2].ColumnHidden = True
Me.[S/F 2].ColumnHidden = True

1637140841856.png
 

June7

AWF VIP
Local time
Today, 07:13
Joined
Mar 9, 2014
Messages
5,488
If form (or subform) is not in datasheet view, then there are no columns to hide. Set a form for datasheet view with DefaultView property. If you don't know how to do this, then why does your image look like datasheet?

Can't use both versions of code in the same place. One example is for behind main form and one for behind subform.

Hiding column with OnCurrent event won't hide just for that record - it hides for ALL records.

Is subform container control named subview or sebview?

Really should have Option Explicit at top of every code header.
https://docs.microsoft.com/en-us/of...User-Interface-Help/option-explicit-statement
Will have to manually type into existing modules but can set Access to automatically include this for new modules.
On the VBA editor menu > Tools > Options > check Require Variable Declaration
 
Local time
Today, 16:13
Joined
Oct 31, 2021
Messages
42
If form (or subform) is not in datasheet view, then there are no columns to hide. Set a form for datasheet view with DefaultView property. If you don't know how to do this, then why does your image look like datasheet?

Can't use both versions of code in the same place. One example is for behind main form and one for behind subform.

Hiding column with OnCurrent event won't hide just for that record - it hides for ALL records.

Is subform container control named subview or sebview?

Really should have Option Explicit at top of every code header.
https://docs.microsoft.com/en-us/of...User-Interface-Help/option-explicit-statement
Will have to manually type into existing modules but can set Access to automatically include this for new modules.
On the VBA editor menu > Tools > Options > check Require Variable Declaration

I'm trying on it

Thank you
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 11:13
Joined
Feb 19, 2002
Messages
43,370
I would not recommend hiding the columns. If you want to make the database more efficient, then you should normalize the schema. That would make each of the S/F columns a row in a child table rather than a column so you would only see as many rows as exist and each row would have its own date and comment. You would use a subform to show the details.

You can always hid the columns manually if they are in the way. The code that was suggested simply hides the column whether it is empty or not. To only hide the column if it is empty, you need to use a dCount() for each column. Once the column is hidden, you have to have some way to unhide it if you need to add data to it.
 

Users who are viewing this thread

Top Bottom