Solved How to hide a calculated control on a form. (1 Viewer)

moi

Member
Local time
Today, 15:51
Joined
Jan 10, 2024
Messages
188
I know this is a basic thing for expert here, but my knowledge of vba is very limited as of now..

I want to hide my calculated control on main form (based on subform control) if the control is no data, null or 0.. Thinking to put some code on my main form on current/open, but no idea what code.

Can someone pls help me..

Thank you..
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:51
Joined
Oct 29, 2018
Messages
21,467
How about?
Code:
If Nz(Me.ControlName,0)=0 Then
    Me.ContolName.Visible = False
End If
 

Gasman

Enthusiastic Amateur
Local time
Today, 08:51
Joined
Sep 21, 2011
Messages
14,253
I know this is a basic thing for expert here, but my knowledge of vba is very limited as of now..

I want to hide my calculated control on main form (based on subform control) if the control is no data, null or 0.. Thinking to put some code on my main form on current/open, but no idea what code.

Can someone pls help me..

Thank you..
Here is a great resource where I have found for a lot of code and how to do things with Access.

And uisng it with a simple phrase
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 03:51
Joined
Feb 19, 2002
Messages
43,257
I want to hide my calculated control on main form (based on subform control) if the control is no data, null or 0..
I'm assuming that this control is unbound and in the subform's footer because it makes no sense whatsoever to use a bound subform control for this purpose.

The code to set the visibility belongs in the main form's Current event. You also need to toggle it.

Code:
If Nz(Me.ControlName,0)=0 Then
    Me.ContolName.Visible = False
else
    Me.ControlName.Visible = True
End If
 
Last edited:
  • Like
Reactions: moi

moi

Member
Local time
Today, 15:51
Joined
Jan 10, 2024
Messages
188
I'm assuming that this control is unbound and in the subform's footer because it makes no sense whatsoever to use a bound subform control for this purpose.

The code to set the visibility belongs in the main form's Current event. You also need to toggle it.

Code:
If Nz(Me.ControlName,0)=0 Then
    Me.ContolName.Visible = False
else
    Me.ControlName.Visible = True
End If
Hi Pat,
Thank u, Yes my control is unbound and it sits on mainform..
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 03:51
Joined
Feb 19, 2002
Messages
43,257
Yes my control is unbound and it sits on mainform..
I was referring to the subform control. Since a subform has multiple rows, it makes absolutely NO SENSE to reference a subform control from the main form. Which row are you referring to? But, a common use is to add a control to the subform's footer that sums values in the subform. Then the code you are using copies that hidden control from the subform footer and displays the value on the main form.
 

moi

Member
Local time
Today, 15:51
Joined
Jan 10, 2024
Messages
188
I was referring to the subform control. Since a subform has multiple rows, it makes absolutely NO SENSE to reference a subform control from the main form. Which row are you referring to? But, a common use is to add a control to the subform's footer that sums values in the subform. Then the code you are using copies that hidden control from the subform footer and displays the value on the main form.
Hi Pat,
My bad, yes i have a control sits on subform's header which sums up a control, then i have a unbound control on mainform to display the value.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 03:51
Joined
Feb 19, 2002
Messages
43,257
OK, that works. Just make sure you toggle the visible property. Otherwise, if you scroll to a new record with a different value, the control won't become visible.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 02:51
Joined
Feb 28, 2001
Messages
27,156
@Gasman - you are probably correct in that it was an AI-generated response by Shao6. I'd give it 0 for style points since we prefer the more personal touch with responses, but I give it at least 1 point for technical correctness.
 

GPGeorge

Grover Park George
Local time
Today, 00:51
Joined
Nov 25, 2004
Messages
1,838
To hide a calculated control on a form, you can typically adjust its visibility property in the form's design view. First, locate the calculated control you want to hide. Then, access the properties window for that control. Look for the "Visible" property and set it to "No" or "False." This will hide the control from view when the form is displayed to users. By toggling the visibility property, you can control whether the calculated control is shown or hidden on the form. This feature is useful for presenting information dynamically based on user interactions or specific conditions without cluttering the form interface.
Did you actually TRY this before posting the AI generated response? The last sentence is the give-away, btw, that this is most likely AI generated material. Who comments on the general usefulness of features? AI does, people mostly don't.

One has a responsibility, IMO, NOT to simply copy/paste AI generated responses in any forum. And, further to identify it clearly as such in any event.

Like The_Doc_Man said, this answer may, or may not, be technically accurate. The problem is that far too many people rely blindly on AI in general with no backing knowledge to ensure that the material is valid, relevant or usable.
 

Users who are viewing this thread

Top Bottom