Problem with tab page visibility code

A

Amit

Hi,

Any help with this will be appreciated. I'm not sure
what's causing this problem.

I have a form with 2 subforms on two different pages of a
tabcontrol. I have a combobox on the main form, with a
default value of "". The two possible values to be
selected are "Individual" or "Organization". I'd like the
tabcontrol to be invisible on a new record, and the
appropriate tabcontrol page to be made visible depending
on the value selected through the combobox.

I have the following code:

Private Sub Form_Current()
If (Me.cboContributorType_frmContribution = "") Then
Me.TabCtl20.Visible = False
Else
If (Me.cboContributorType_frmContribution
= "Individual") Then
Me.TabCtl20.Pages(0).Visible = True
Me.TabCtl20.Pages(1).Visible = False
Else
If (Me.cboContributorType_frmContribution
= "Organization") Then
Me.TabCtl20.Pages(1).Visible = True
Me.TabCtl20.Pages(0).Visible = False
End If
End If
End If
End Sub
~~~~~~~~~~~~
and the following code in the OnEnter and AfterUpdate
properties of the combobox:

Private Sub cboContributorType_frmContribution_Enter()
If Me.cboContributorType_frmContribution
= "Individual" Then
Me.TabCtl20.Pages(0).Visible = True
Me.TabCtl20.Pages(1).Visible = False
Else
If Me.cboContributorType_frmContribution
= "Organization" Then
Me.TabCtl20.Pages(0).Visible = False
Me.TabCtl20.Pages(1).Visible = True
Else
If Me.cboContributorType_frmContribution = ""
Then
Me.TabCtl20.Visible = False
End If
End If
End If
End Sub
~~~~~~~~~
This is not working properly. When I open the form, I see
the appropriate tabcontrol page for existing records, but
when I go to a new record, and select the value from the
combobox, the appropriate page is not displayed. When I
close the form and re-open it and go to the last record, I
see the page being displayed. Not sure why....

Any help will be appreciated.

Thanks!!!!

-Amit
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top