none
How to reset a ComboBox? RRS feed

  • Question

  • Hi All

    I have a Combo box on a form and the form has about 10 text boxes and all the values are coming from Query, when I select the value in a combo box, it will display according that value, however when I don't select anything also then also the values in the text boxes still exist, how do I reset to empty values in the text box.

    Also if the value is entered in one of the text box which has unique value, it should be able to display values on the other text boxes, is it possible?
    Thank You

    Wednesday, December 20, 2017 8:21 PM

All replies

  • Hi,

    How are you displaying the data in the Textboxes from the Combobox? Are you using any code? If so, can you show us an example? Also, what do you mean when you say you don't select anything? If you click on the dropdown but don't do anything, then no event will fire.

    Wednesday, December 20, 2017 8:36 PM
  • Thank you,

    I am displaying it from just selecting the 3rd option Find a Record on the form by selecting the value from Combo box, when the form runs, the Combo box opens with no value, but all the text boxes have value, so first when we open, all the text boxes should not have value and when toggle back in Combo box, it should display all the values(it is doing that already) and again when we go back to no value in Combo box, all the text boxes should not have any value. How to accomplish this?

    Wednesday, December 20, 2017 8:47 PM
  • Hi,

    Thanks for the clarification. To initially open the form with empty values, you can do either of two ways:

    1. Open to an empty Recordset, or

    2. Navigate the form to a New Record

    So, for #2, in the Open event of the form, you can try something like:

    DoCmd.GoToRecord , , acNewRec

    As for resetting all the boxes when the Combobox is empty, we'll need to modify the code the Wizard created.

    Can you please post the code, so we can show you which lines to change? Thanks.

    Wednesday, December 20, 2017 9:16 PM
  • Hi gaby-usa,

    you had mentioned that," when the form runs, the Combo box opens with no value, but all the text boxes have value, so first when we open, all the text boxes should not have value and when toggle back in Combo box, it should display all the values(it is doing that already) and again when we go back to no value in Combo box"

    you can try to use DLookup on combobox_change event.

    below is an example:

    Private Sub Combo0_Change()
        If Me.Combo0.Text = "" Then
            Me.Text2 = ""
        Else
            Dim strOrgName As String
            strOrgName = DLookup("rate", "Table1", "[product]='" & Me.Combo0.Text & "'")
            Me.Text2 = strOrgName
        End If
    End Sub
    

    Output:

    Reference:

    DLookup Function

    ComboBox.Change Event (Access)

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, December 21, 2017 1:53 AM
    Moderator
  • Hi gaby-usa,

    is your issue solved?

    I find that you did not follow up this thread for a long time.

    if your issue is solved then I suggest you to post your solution and mark it as an answer.

    if your issue is still exist then try to refer the solution given by me.

    if then also you have any further questions then let me know about it.

    I will try to provide further suggestions to solve the issue.

    Thanks for your understanding.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, December 26, 2017 3:06 AM
    Moderator