Hiding parts of a form or making them greyed out (1 Viewer)

darth sidious

Registered User.
Local time
Yesterday, 19:38
Joined
Feb 28, 2013
Messages
86
Hi

I need help hiding parts of a form if a option button is selected. There are two option buttons and two parts to the form. I would like each part of the form greyed out or made invisible depending on which radio option button is selected.

Can anyone tell me how I can achieve this.

Thanks

Darth
 

burrina

Registered User.
Local time
Yesterday, 21:38
Joined
May 10, 2014
Messages
972
Do you mean controls on a form? Example;

If Me.SomeField = True Then 'Purpose: Disable Control
Me.SomeField.Enabled = False
End If

HTH
 

darth sidious

Registered User.
Local time
Yesterday, 19:38
Joined
Feb 28, 2013
Messages
86
Hi

Yes, but how can I achieve that through the macro builder or other menus as I'm not comfortable using code.

Thanks


Darth
 

burrina

Registered User.
Local time
Yesterday, 21:38
Joined
May 10, 2014
Messages
972
You would use that on OnCurrentEvent for the form.
Also if the value changes, you will also need the enter the same code using the AfterUpdateEvent for the control.
 

darth sidious

Registered User.
Local time
Yesterday, 19:38
Joined
Feb 28, 2013
Messages
86
You would use that on OnCurrentEvent for the form.
Also if the value changes, you will also need the enter the same code using the AfterUpdateEvent for the control.


Hi

Could you provide a list of steps as I have no idea how to implement this.

I have an option button called OptManager, when this is checked I want it to lock/hide a combo box called cboOther and a subform called subformOther.

Thanks

Darth
 

burrina

Registered User.
Local time
Yesterday, 21:38
Joined
May 10, 2014
Messages
972
Okay,here you go!

If Me.OptManager = -1 Then
Me.cboOther.Enabled = False
Me.subformOther.[Form].Visible = False
End If

HTH
 

pr2-eugin

Super Moderator
Local time
Today, 03:38
Joined
Nov 30, 2011
Messages
8,494
Go to the Form's Design view, go to the Property Sheet, in the tab Events, locate the On Current. Check out the My First VBA, to understand how to create an Event Procedure. (follow the image).

Then, use the code inbetween the Private Sub Form_Current() and End Sub.

You say its an Option button, in that case how many options are there? What are the Option button values? That is what you need to use in your code. IMVHO, if the choices go beyond 3, go for a Select case. If it is only two, If Else would suffice.
Code:
Private Sub Form_Current()
    If Me.OptManager = 1 Then
        Me.cboOther.Enabled = False
        Me!subformOther.Form.Visible = False
    Else
        Me.cboOther.Enabled = True
        Me!subformOther.Form.Visible = True
    End If
End Sub
 

darth sidious

Registered User.
Local time
Yesterday, 19:38
Joined
Feb 28, 2013
Messages
86
Go to the Form's Design view, go to the Property Sheet, in the tab Events, locate the On Current. Check out the My First VBA, to understand how to create an Event Procedure. (follow the image).

Then, use the code inbetween the Private Sub Form_Current() and End Sub.

You say its an Option button, in that case how many options are there? What are the Option button values? That is what you need to use in your code. IMVHO, if the choices go beyond 3, go for a Select case. If it is only two, If Else would suffice.
Code:
Private Sub Form_Current()
    If Me.OptManager = 1 Then
        Me.cboOther.Enabled = False
        Me!subformOther.Form.Visible = False
    Else
        Me.cboOther.Enabled = True
        Me!subformOther.Form.Visible = True
    End If
End Sub



Hi

This is the uptodate data I am using, I have followed your steps and done the following:

Private Sub Detail_Click()
If Me.optActor = 1 Then
Me.cboAvailableCharacter.Enabled = False
Me!qryCharacterDetails subform.For.Visible = False
Else
Me.cboAvailableCharacter.Enabled = True
Me!qryCharacterDetails subform.Form.Visible = True
End If
End Sub


However, it doesnt like the space in the name of my subform but even when I remove that it still throws back errors.

Any further advice?


Thanks

Darth
 

pr2-eugin

Super Moderator
Local time
Today, 03:38
Joined
Nov 30, 2011
Messages
8,494
Thought your subform name was sunformOther? Well having spaces (which is against rule 101 in the naming convention) in control names need to be enclosed within square brackets Me![qryCharacterDetails subform].Form.Visible = False.

PS : Please use Code Tags when posting VBA Code
 

darth sidious

Registered User.
Local time
Yesterday, 19:38
Joined
Feb 28, 2013
Messages
86
Thought your subform name was sunformOther? Well having spaces (which is against rule 101 in the naming convention) in control names need to be enclosed within square brackets Me![qryCharacterDetails subform].Form.Visible = False.

PS : Please use Code Tags when posting VBA Code


Hi

I have done the above with square brackets:

Code:
Private Sub Detail_Click()
If Me.optActor = 1 Then
        Me.cboAvailableCharacter.Enabled = False
        Me![qryCharacterDetails subform].For.Visible = False
    Else
        Me.cboAvailableCharacter.Enabled = True
        Me![qryCharacterDetails subform.Form].Visible = True
    End If
End Sub

But I get a runtime error 2427 you entered an expression that has no value.

Thanks
 

pr2-eugin

Super Moderator
Local time
Today, 03:38
Joined
Nov 30, 2011
Messages
8,494
Really???
Code:
[SIZE=4][COLOR=Red][B]Private Sub Detail_Click()[/B][/COLOR][/SIZE]
If Me.optActor = 1 Then
        Me.cboAvailableCharacter.Enabled = False
        Me![qryCharacterDetails subform].For.Visible = False
    Else
        Me.cboAvailableCharacter.Enabled = True
        Me![qryCharacterDetails subform.Form].Visible = True
    End If
End Sub
:rolleyes:
 

darth sidious

Registered User.
Local time
Yesterday, 19:38
Joined
Feb 28, 2013
Messages
86
Really???:rolleyes:


OK iVE changed it to form_current()

no errors but the combo and subform are still displayed whether my option box is ticked ot not.


Infact still same error message: run time error 2427 you have entered an expresion that has no value.
 

pr2-eugin

Super Moderator
Local time
Today, 03:38
Joined
Nov 30, 2011
Messages
8,494
whether my option box is ticked ot not.
Terminology might be a barrier !

Option Group - An option group on a form or report displays a limited set of alternatives. An option group makes selecting a value easy since you can just click the value you want. Only one option in an option group can be selected at a time.

Checkbox - The CheckBox control enables users to select and clear options in an application's user interface (UI).

So what do you have? Checkbox or Option Group (with a Check instead of radio buttons?)
 

darth sidious

Registered User.
Local time
Yesterday, 19:38
Joined
Feb 28, 2013
Messages
86
Terminology might be a barrier !

Option Group - An option group on a form or report displays a limited set of alternatives. An option group makes selecting a value easy since you can just click the value you want. Only one option in an option group can be selected at a time.

Checkbox - The CheckBox control enables users to select and clear options in an application's user interface (UI).

So what do you have? Checkbox or Option Group (with a Check instead of radio buttons?)


I have an option group
 

burrina

Registered User.
Local time
Yesterday, 21:38
Joined
May 10, 2014
Messages
972
Can you post a Demo copy of your db with all confidential data removed?
 

Users who are viewing this thread

Top Bottom