Loading Subform Based on Value on Main Form

databasedonr

Registered User.
Local time
Today, 11:26
Joined
Feb 13, 2003
Messages
163
I have a text box on my main form that contains a value set from a value list. There are three possible values, and only values from the list can be used.

Based on the values, I want to display a different subform as part of my main form, but I am not sure how to do this.

For example, if my three values are Active, Inactive, Unavailable, I want to do the following:

If Active display NO subforms

If Inactive display Inactive Subform

If Unavailable, display Unavailable subform.

The rationale here is, if the asset is active, it's being used, but if it is inactive or unavailabe, I have different tables that provide information about the status.

Excuse my ignorance, and any advice is more than welcome!

Thanks in advance.
 
Set up some code in the AfterUpdate event of your text box to control the state of the subforms' visibility.

The code can look something like this (I'll assume your text box is called txtStatus:
Select Case Me.txtStatus
  Case is = "Active"
    'stuff to do
  Case is = "Inactive"
    'stuff to do
  Case is = "Unavailable"
    'stuff to do
End Select

The generic code to set a subform's (or any objects visibility) is:
Me.objectname.Visible=False
 
Thanks! That worked. More kudos for the forums, and thanks to the secretive dcx693 for the advice!

In case anyone is interested, this is the actual code:

Select Case Me.txtStatus
Case Is = "Active"
Me.fSubLoanedItems.Visible = False
Me.fSubInactiveItems.Visible = False
Case Is = "Inactive"
Me.fSubInactiveItems.Visible = True
Me.fSubLoanedItems.Visible = False
Case Is = "Loaned"
Me.fSubInactiveItems.Visible = False
Me.fSubLoanedItems.Visible = True

End Select
 
Last edited:

Users who are viewing this thread

Back
Top Bottom