Resetting a control value - InfoPath Dev
in

InfoPath Dev

Resetting a control value

Last post 09-28-2008 11:08 AM by dbaldacchino. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 09-26-2008 04:45 PM

    Resetting a control value

    I have two drop-down list boxes: LB1 and LB2. LB1 pulls values from an Access table and LB2 then displays a filtered list of options (also pulled from an Access table) based on LB1's value. So far, so good.

    The issue is that if the user then goes back and changes the value of LB1, now LB2 is set to a potentially wrong value so I would like to reset LB2 when LB1 is changed, so the user is forced to go back and reselect. I know how to achieve this with VBA in Access, but I'm having trouble with VB. Here's an example in VBA:

    Private Sub lblDisciplineID_AfterUpdate()

    Static DisciplineUPDated As String
    If DisciplineUPDated = "" Then DisciplineUPDated = Me.lblDisciplineID.OldValue

    Me.lblDetail_Type.Requery ' This refreshes the query that populates the combo box in the Access form
    If DisciplineUPDated <> Me.lblDisciplineID.Value Then
        Me.lblDetail_Type.Value = Null
        Me.lblSubfolderID.Value = Null
        DisciplineUPDated = Me.lblDisciplineID.Value
    End If
    Me.lblDetail_Type.SetFocus

    End Sub

    Any help with how I could do something similar in Infopath with VB (or any other method I might be overlooking) would be greatly appreciated. I've already tried using Rules but I can't seem to find a solution. Thanks!

  • 09-27-2008 11:16 PM In reply to

    Re: Resetting a control value

    It is simple to do with rules in InfoPath.

    Create a rule for LB1.

    Make the condition LB2 is not null then set field lb2 to null.

  • 09-27-2008 11:27 PM In reply to

    Re: Resetting a control value

    Thanks Clay. However I don't need to test for LB1 being Null, but being changed from a previous value. That doesn't seem possible with rules.

  • 09-27-2008 11:31 PM In reply to

    Re: Resetting a control value

    Ignore me...your solution works perfectly. It was a lot simpler than I thought! Thanks a lot.

  • 09-27-2008 11:32 PM In reply to

    Re: Resetting a control value

    A rule on LB1 will fire each time it is changed.

    After thinking about it you do not even need to make it conditional.

    Just reset LB2 to null or empty string each time LB1 is changed. If it resets it the first time no matter.

    This would give you what you are looking for.

     

  • 09-28-2008 03:03 AM In reply to

    Re: Resetting a control value

    Hi Clay,

    I have tried setting the value to "" on a button click as suggested for a list box. but it is not removingt all the items of the list box. Any suggestions?

  • 09-28-2008 11:08 AM In reply to

    Re: Resetting a control value

    I left the value empty (did not put the double quotation marks) and it's working for me. I'm using a drop-down list box.

Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.