changing object visibility state after changing records

Konai

Registered User.
Local time
Today, 06:31
Joined
Dec 7, 2009
Messages
17
Hello, I am trying to make a form that only has certain fields visible based on a selection within an option group. I have a script to change the visibility states based on what is selected.

Code:
Private Sub ffoVis()
    Me.EventDate.SetFocus
    Me.lblPackRecv.Visible = False
    Me.Packages_Received.Visible = False
    Me.lblPackCount.Visible = False
    Me.txtPackCount.Visible = False
    Me.lblWhere.Visible = False
    Me.txtWhere.Visible = False
    If Me.Contact_Type.Value = 2 Then
        Me.lblWhere.Visible = True
        Me.txtWhere.Visible = True
        Me.Packages_Received.Value = Null
        Me.txtPackCount.Value = Null
    ElseIf Me.Contact_Type.Value = 5 Then
        Me.lblPackRecv.Visible = True
        Me.Packages_Received.Visible = True
        Me.lblPackCount.Visible = True
        Me.txtPackCount.Visible = True
        Me.txtWhere.Value = Null
    Else
        Me.Packages_Received.Value = Null
        Me.txtPackCount.Value = Null
        Me.txtWhere.Value = Null
    End If
End Sub

Based on the selection within the combo box (1, 2, 3, 4, 5, or
nothing<- when i make a new record. I would like to update the objects so that only the ones that I want to be visible are visible.

Also... I would like to be able to view the relevant fields for each record as I am scrolling through the records. (Based on the selection in the option group)

Thank you!
 
Your post is somewhat confusing, as first you refer to an Option Group then you refer to a Combobox, but the approach is the same for either. The code/function needs to be run form the Combobox or Option Group AfterUpdate event and, assuming that it's bound to a field in the underlying table (it has to be, obviously, to persist like you want) in the Form_Current event, as well.
 
Thank you!.. I meant option group, not combo box. Sorry for that confusion.
I will try Form_Current and After_Update when I have some time to work on it again. I'll post another reply as to the outcome. Thank you again.

Edit

Ok the on current (Form_Current) option was what it was .. I couldn't figure it out with so many different options.
It now handles it just the way I wanted it to. with only one line added to what I had before it now works perfectly :D. Thanks a ton!

Code:
Private Sub Contact_Type_Click()    
    Call ffoVis
End Sub

Private Sub ffoVis()
    Me.EventDate.SetFocus
    Me.lblPackRecv.Visible = False
    Me.Packages_Received.Visible = False
    Me.lblPackCount.Visible = False
    Me.txtPackCount.Visible = False
    Me.lblWhere.Visible = False
    Me.txtWhere.Visible = False
    If Me.Contact_Type.Value = 2 Then
        Me.lblWhere.Visible = True
        Me.txtWhere.Visible = True
        Me.Packages_Received.Value = Null
        Me.txtPackCount.Value = Null
    ElseIf Me.Contact_Type.Value = 5 Then
        Me.lblPackRecv.Visible = True
        Me.Packages_Received.Visible = True
        Me.lblPackCount.Visible = True
        Me.txtPackCount.Visible = True
        Me.txtWhere.Value = Null
    Else
        Me.Packages_Received.Value = Null
        Me.txtPackCount.Value = Null
        Me.txtWhere.Value = Null
    End If
End Sub

Private Sub Form_Current()
    Call ffoVis
End Sub
 
Last edited:

Users who are viewing this thread

Back
Top Bottom