Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Combo Change - Check Before/After Values and Other Combos Before Change (Update)?

Status
Not open for further replies.

misscrf

Technical User
Jun 7, 2004
1,344
US
I have 3 combos. The first one is to pick the type of voting panel. Some of the options are a panel type (column(2) - hidden) of a person, the others are a group. If the type of voting panel chosen is a type of person, a person combo is shown. If the type of voting panel chosen is a group, a group combo is shown.

Now, this is all fine and well, I can make a function in the form, to be used for navigation and initial setting of the combos, but my problem comes after a choice is made.

Say a person type is already chosen, and a person is chosen from the person combo. If a user goes to change the type of voting panel, I have to catch what type they are trying to change it to. If they are changing it to a type that is a group, I need to warn them that they can only have one type, and that we will wipe out the person already chosen. Does that make sense?

This is the function I call throughout the form's navigation (below). I just need to only call this, if they are ok with changing the value, i.e. if they do want to change the combo, I have to wipe out the value they had put, if the type they are changing to is the opposite of what it was (person or group).

Code:
Function checkvPanelType()
    Dim vPanelType As Integer
    vPanelType = Nz(Me.FKvPanelType.Column(2), 0)

    If dvPanelType = 0 Then
        Me.FKGroup.Visible = False
        Me.FKPerson.Visible = False
        Me.FKGroup.Value = ""
        Me.FKPerson.Value = ""
    ElseIf dvPanelType = 1 Then
        Me.FKGroup.Visible = False
        Me.FKPerson.Visible = True
        Me.FKGroup.Value = ""
    ElseIf dvPanelType = 2 Then
        Me.FKGroup.Visible = True
        Me.FKPerson.Visible = False
        Me.FKPerson.Value = ""
    End If
End Function

My thought is that before update of the vPanelType combo, I need to get what the value was/is, and what they are attempting to change that combo to. By accessing the type, I can determine if they are changing from a person type to a group type, and vice versa. If they are switching that type, then I simply ask them if they are ok with removing the person/group already named, so they can choose a new one of the opposite type.

My challenge, is how to access the value that the combo is before they try to change it, and what they are trying to change it to.

Any help would be greatly appreciated.


misscrf

It is never too late to become what you could have been ~ George Eliot
 
It maybe just me, but that approach seems very convoluted, especially for voting. 3 combo boxes, voter changes something, you want to know what was there before…

If the major choice is: a person or a group, and those 2 choices will never increase, I would have 2 option buttons and just one combo box.

O Person
O Group

If “Person” is selected (by default maybe?), populate combo with people to select a person
If ‘Group’ is selected, populate (the same) combo with groups to select a group.

And a command button: “Cast My Vote” where you can have a message box:
“I vote for a Peron: Joe Smith” Yes / No, or
“I vote for a Group: ABBA” Yes / No

Why do you care if selection have been changed from Person to Group, or vice versa?

As a side note, I would not use Function since Function returns a value.
I would just use a Sub, with this simpler (IMHO) code: [pc1]

Code:
Sub checkvPanelType()
    Dim vPanelType As Integer
    vPanelType = Nz(Me.FKvPanelType.Column(2), 0)

    Me.FKGroup.Visible = False
    Me.FKPerson.Visible = False
    Me.FKGroup.Value = ""
    Me.FKPerson.Value = ""

    Select Case dvPanelType
        Case 1
            Me.FKPerson.Visible = True
        Case 2
            Me.FKGroup.Visible = True
    End Select

End Sub

---- Andy

There is a great need for a sarcasm font.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top