Results 1 to 5 of 5

Thread: Combo box query

  1. #1
    Lounger
    Join Date
    Mar 2003
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Combo box query

    I created a combo box that reads its menu using an SQL statement that has a "where" command and uses value of a control into the sql statement. The value of this control changes as I go from one record to the other. The idea is that for every record, when I go to the combo box, it should run the SQL statement, generate the output and use it into the menu for the combo box.

    But this happens only for the first record for which I used the combo box. For every subsequent record, the combo box displays the same menu. In other words, the SQL statement is not run afresh everytime I go to the combo box. It is run only once and every next time the same menu is displayed.

    How can I sort this out?

  2. #2
    DAW
    Guest

    Re: Combo box query

    If I have understood your question properly then this might help:-

    Private Sub Form_Current()
    cboYourField.Requery
    End Sub

    Dave.

  3. #3
    Lounger
    Join Date
    Mar 2003
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo box query

    Thanks very much for your reply. Requery seems to me exactly what I need. But there is still a problem. The control on which I want to run it is on a subform. In that case, where and when should this event occur?

    I am attaching part of the database. I've zipped it to keep it below 100 KB. The main form is "Household2001". The combo box on which requery needs to run is on the subform (Individuals2001) and is called "Name".

    Could you tell me how to execute the event?

    Vikas Rawal
    vikasrawal@netkracker.com
    Attached Files Attached Files

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Combo box query

    Start by changing the name of the combobox. Name is a defined property in Access, which effectively makes it a reserved word, whether or not it's on the list. If you want to requery a combobox on a subform from the parent form, the syntax is:

    Me!subformControl.form!combobox.requery
    Charlotte

  5. #5
    Lounger
    Join Date
    Mar 2003
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo box query

    Thanks Charlotte and Dave. That does it.

    Problem solved. Great. Thank you.

    Vikas

Posting Permissions

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