MS Access 2003 Forms

AnnMV888

Registered User.
Local time
Today, 07:57
Joined
Mar 1, 2010
Messages
15
I have a field called txtSessionType. There are five possible types and of these five they open three different subforms.

The types Coaching Session and Side by Side Coaching Session open the subfrmEmployeeSessionsCalls.

The types Personal Development Session and Other Documentation Session open the subfrmOtherSessions.

The type Monthly Review opens the subfrmMonthlyReviewSession.

I can open the different subforms based on the condition of different types. The problem is I don't know how to close the form that no longer is needed if the txtSessionType was changed to a type that uses one of the other forms. I'm not a programmer so I'm pretty lost. Here is what I have so far.

If Me.subfrmEmployeeSessions.Form.txtSessionType Like "Coaching Session" Then
Me.subfrmEmployeeSessions.Form.subfrmEmployeeSessionsCalls.Form.Visible = True
ElseIf Me.subfrmEmployeeSessions.Form.txtSessionType Like "Side by Side Coaching Session" Then
Me.subfrmEmployeeSessions.Form.subfrmEmployeeSessionsCalls.Form.Visible = True
Else
Me.subfrmEmployeeSessions.Form.subfrmEmployeeSessionsCalls.Visible = False
End If


Thanks in advance.
 
Code:
Select Case Me.subfrmEmployeeSessions.Form.txtSessionType
    Case "Coaching Session" , "Side by Side Coaching Session"
          Me.subfrmEmployeeSessions.Form.subfrmEmployeeSessionsCalls.Form.Visible = True
        Me.subfrmEmployeeSessions.Form.subfrmOtherSessions.Visible = False      
    Case Else
        Me.subfrmEmployeeSessions.Form.subfrmOtherSessions.Visible = True
        Me.subfrmEmployeeSessions.Form.subfrmEmployeeSessionsCalls.Form.Visible = False
End Select

I changed the nested if to a Select Case which is easier to read and modify.
 
Thank you for the help. I learned something new in VBA and it was very easy to understand and add the other cases that I needed.

This was my first post and I didn't see any points to assign so I hope I didn't miss something...again, thanks!!
 
I thought you only had 5 cases. Two that opened one form and the rest opened a different form. The code I suggested handled all those.
 
No, I had five that opened three forms.

The types Coaching Session and Side by Side Coaching Session open the subfrmEmployeeSessionsCalls.

The types Personal Development Session and Other Documentation Session open the subfrmOtherSessions.


The type Monthly Review opens the subfrmMonthlyReviewSession.

I was able to follow what you did and add the others.
 

Users who are viewing this thread

Back
Top Bottom