Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2002
    Posts
    55

    Wink Unanswered: Clearing Form Fields

    I am trying to learn a bit about Access and I am running into a problem. I have a form that has two drop-down boxes (category/subcategory).

    Based on what is selected in the category drop-down will determine what is available in the subcategory drop-down.

    That portion is working fine. However, if I decide to change whatever the initial value of the category field is, the old subcategory value is still displayed until I select a new record from the subcategory drop-down.

    I am looking for a way to have the subcategory automatically clear itself out as soon as a selection is made on the category field.

    Any input would be much appreciated.

    Thanks!

    Hirk

  2. #2
    Join Date
    Nov 2001
    Posts
    336
    Suppose you have comboboxes cboCategory and cboSubCategory. Then in afterupdate event for cboCategory put following code.

    cboSubCategory.Rowsource = "Select LookupValues From tblLookups Where Category='" & me.cboCategory & "';"

    HTH

  3. #3
    Join Date
    Feb 2002
    Posts
    55
    Thanks for the input. That does the trick for the lookups, but if I selected a value already, it doesn't clear out the box.

    For example, if I select:

    Category: Sports
    Subcategory: Football

    then I go back and change sports to "Recipes" it will look like this:

    Category: Recipes
    Subcategory: Football

    I then need to manually delete "Football" for the lookup to be accurate. I am looking to have the subcategory field flushed to a null as soon as I select a different category.

  4. #4
    Join Date
    Nov 2001
    Posts
    336
    OK, try this:

    cboSubCategory.Rowsource = "Select LookupValues From tblLookups Where Category='" & me.cboCategory & "';"
    cboSubCategory = NZ(DLookup("LookupValues","tblLookups","Category=' " & me.cboCategory & "'"),1)

    HTH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •