display/hide subform dependent on combo box selection

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi.

Is it possible to either:
1) group a set of controls on the main form, hide the group and have it only
appear or not appear dependent on the selection in a combo box, or if not,
2) hide a subform that includes these controls and have the subform appear
or not appear dependent on the selection in the combo box?

If so, please advise.

Thanks!
 
Hi, Nicolle.

Sure. For main form controls, something like:

If Me![cboMyComboBox] = 6 Then
With Me![txtMyControl]
.Enabled=False
.Visible = False
End With
End If

You could either name each specifically, or if they have consecutive index
numbers, loop through them.

Disable the subform the same way; its just another control on the main form.

If you wish to disable a *particular* control on the subform, just refer to
it:

If Me![cboMyComboBox] = 6 Then
With Me![sbfMySubform].Form![txtMyControl]
.Enabled=False
.Visible = False
End With
End If

HTH
Sprinks
 
Thanks very much!

Please excuse my ignorance but...
Where would I enter the code? In the code builder or expression builder? I
tried it in the code builder. My code look likes this:

Private Sub TD_AfterUpdate(Cancel As Integer)
If Me![TD] = "Submission - abstract" Then
With Me![Title]
..Enabled = True
..Visible = True
End With
End Sub

When I try to open the form, I am getting an error message that says: "The
LinkMasterFields property setting has produced the following error:
'Procedure declaration does not match description of event or procedure
having the same name'"

Does this mean anything to you? Is there are anything that I am obviously
doing wrong?

By the way, what does "HTH" mean?

Thanks again! -Nicolle



Sprinks said:
Hi, Nicolle.

Sure. For main form controls, something like:

If Me![cboMyComboBox] = 6 Then
With Me![txtMyControl]
.Enabled=False
.Visible = False
End With
End If

You could either name each specifically, or if they have consecutive index
numbers, loop through them.

Disable the subform the same way; its just another control on the main form.

If you wish to disable a *particular* control on the subform, just refer to
it:

If Me![cboMyComboBox] = 6 Then
With Me![sbfMySubform].Form![txtMyControl]
.Enabled=False
.Visible = False
End With
End If

HTH
Sprinks

nicolle said:
Hi.

Is it possible to either:
1) group a set of controls on the main form, hide the group and have it only
appear or not appear dependent on the selection in a combo box, or if not,
2) hide a subform that includes these controls and have the subform appear
or not appear dependent on the selection in the combo box?

If so, please advise.

Thanks!
 
Hi, Nicolle.

Yes, enter the code for the AfterUpdate event of your combo box. Basically,
the idea is that Access has all kinds of events. When an event occurs that
has code defined for it, Access runs the code. Because there are many
events, you have a great deal of flexibility in controlling the application’s
behavior.

I’m not familiar with this error, but you’re missing the End If of your
If…Then block, which is probably the culprit. If not, please post the Name
of your combo box, and the LinkMasterField and LinkChildField properties of
the subform. These *should* be the name of the linking field in the main
form’s and the subform’s RecordSource, respectively.

HTH means “Hope That Helpsâ€. Sorry to confuse you.

Sprinks


nicolle said:
Thanks very much!

Please excuse my ignorance but...
Where would I enter the code? In the code builder or expression builder? I
tried it in the code builder. My code look likes this:

Private Sub TD_AfterUpdate(Cancel As Integer)
If Me![TD] = "Submission - abstract" Then
With Me![Title]
.Enabled = True
.Visible = True
End With
End Sub

When I try to open the form, I am getting an error message that says: "The
LinkMasterFields property setting has produced the following error:
'Procedure declaration does not match description of event or procedure
having the same name'"

Does this mean anything to you? Is there are anything that I am obviously
doing wrong?

By the way, what does "HTH" mean?

Thanks again! -Nicolle



Sprinks said:
Hi, Nicolle.

Sure. For main form controls, something like:

If Me![cboMyComboBox] = 6 Then
With Me![txtMyControl]
.Enabled=False
.Visible = False
End With
End If

You could either name each specifically, or if they have consecutive index
numbers, loop through them.

Disable the subform the same way; its just another control on the main form.

If you wish to disable a *particular* control on the subform, just refer to
it:

If Me![cboMyComboBox] = 6 Then
With Me![sbfMySubform].Form![txtMyControl]
.Enabled=False
.Visible = False
End With
End If

HTH
Sprinks

nicolle said:
Hi.

Is it possible to either:
1) group a set of controls on the main form, hide the group and have it only
appear or not appear dependent on the selection in a combo box, or if not,
2) hide a subform that includes these controls and have the subform appear
or not appear dependent on the selection in the combo box?

If so, please advise.

Thanks!
 
Hi Sprinks,

I was able to get it to work. Thanks very much!

Also thank you for clearing up "HTH". I have been wondering about that for a
while. And it definitely did!

-Nicolle



Sprinks said:
Hi, Nicolle.

Yes, enter the code for the AfterUpdate event of your combo box. Basically,
the idea is that Access has all kinds of events. When an event occurs that
has code defined for it, Access runs the code. Because there are many
events, you have a great deal of flexibility in controlling the application’s
behavior.

I’m not familiar with this error, but you’re missing the End If of your
If…Then block, which is probably the culprit. If not, please post the Name
of your combo box, and the LinkMasterField and LinkChildField properties of
the subform. These *should* be the name of the linking field in the main
form’s and the subform’s RecordSource, respectively.

HTH means “Hope That Helpsâ€. Sorry to confuse you.

Sprinks


nicolle said:
Thanks very much!

Please excuse my ignorance but...
Where would I enter the code? In the code builder or expression builder? I
tried it in the code builder. My code look likes this:

Private Sub TD_AfterUpdate(Cancel As Integer)
If Me![TD] = "Submission - abstract" Then
With Me![Title]
.Enabled = True
.Visible = True
End With
End Sub

When I try to open the form, I am getting an error message that says: "The
LinkMasterFields property setting has produced the following error:
'Procedure declaration does not match description of event or procedure
having the same name'"

Does this mean anything to you? Is there are anything that I am obviously
doing wrong?

By the way, what does "HTH" mean?

Thanks again! -Nicolle



Sprinks said:
Hi, Nicolle.

Sure. For main form controls, something like:

If Me![cboMyComboBox] = 6 Then
With Me![txtMyControl]
.Enabled=False
.Visible = False
End With
End If

You could either name each specifically, or if they have consecutive index
numbers, loop through them.

Disable the subform the same way; its just another control on the main form.

If you wish to disable a *particular* control on the subform, just refer to
it:

If Me![cboMyComboBox] = 6 Then
With Me![sbfMySubform].Form![txtMyControl]
.Enabled=False
.Visible = False
End With
End If

HTH
Sprinks

:

Hi.

Is it possible to either:
1) group a set of controls on the main form, hide the group and have it only
appear or not appear dependent on the selection in a combo box, or if not,
2) hide a subform that includes these controls and have the subform appear
or not appear dependent on the selection in the combo box?

If so, please advise.

Thanks!
 
Hi Sprinks,

I was able to get it to work! Thanks so much. Thanks also for clarifying
"HTH". Many people seem to use it and I was wondering about it for a while.

Your code definitely helped!

-Nicolle

Sprinks said:
Hi, Nicolle.

Yes, enter the code for the AfterUpdate event of your combo box. Basically,
the idea is that Access has all kinds of events. When an event occurs that
has code defined for it, Access runs the code. Because there are many
events, you have a great deal of flexibility in controlling the application’s
behavior.

I’m not familiar with this error, but you’re missing the End If of your
If…Then block, which is probably the culprit. If not, please post the Name
of your combo box, and the LinkMasterField and LinkChildField properties of
the subform. These *should* be the name of the linking field in the main
form’s and the subform’s RecordSource, respectively.

HTH means “Hope That Helpsâ€. Sorry to confuse you.

Sprinks


nicolle said:
Thanks very much!

Please excuse my ignorance but...
Where would I enter the code? In the code builder or expression builder? I
tried it in the code builder. My code look likes this:

Private Sub TD_AfterUpdate(Cancel As Integer)
If Me![TD] = "Submission - abstract" Then
With Me![Title]
.Enabled = True
.Visible = True
End With
End Sub

When I try to open the form, I am getting an error message that says: "The
LinkMasterFields property setting has produced the following error:
'Procedure declaration does not match description of event or procedure
having the same name'"

Does this mean anything to you? Is there are anything that I am obviously
doing wrong?

By the way, what does "HTH" mean?

Thanks again! -Nicolle



Sprinks said:
Hi, Nicolle.

Sure. For main form controls, something like:

If Me![cboMyComboBox] = 6 Then
With Me![txtMyControl]
.Enabled=False
.Visible = False
End With
End If

You could either name each specifically, or if they have consecutive index
numbers, loop through them.

Disable the subform the same way; its just another control on the main form.

If you wish to disable a *particular* control on the subform, just refer to
it:

If Me![cboMyComboBox] = 6 Then
With Me![sbfMySubform].Form![txtMyControl]
.Enabled=False
.Visible = False
End With
End If

HTH
Sprinks

:

Hi.

Is it possible to either:
1) group a set of controls on the main form, hide the group and have it only
appear or not appear dependent on the selection in a combo box, or if not,
2) hide a subform that includes these controls and have the subform appear
or not appear dependent on the selection in the combo box?

If so, please advise.

Thanks!
 
Back
Top