Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Populate a form based on ComboBox value (xp)

    I have a form - frmYear9 - that displays details of pupils and their attainments. It is based on a query - qryY9TG - which pulls its values from the combobox on the form. When I choose a TG from the combobox I want the form to display the details of that TG. The query runs successfully by itself, but on opening the form and a TG is selected, no details are displayed. I have set the recordsource of the form to qryTGY9. I hope this is sufficiently detailed and understandable.
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Populate a form based on ComboBox value (xp)

    You probably have to requery the form when you select an item from the dropdown list of the combo box. This can be done in the After Update event of the combo box:

    Private Sub NameOfComboBox_AfterUpdate
    Me.Requery
    End Sub

    where NameOfComboBox must be replaced with the name of ... you guessed it.

  3. #3
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Populate a form based on ComboBox value (xp)

    Perfect! Thanks Hans. It may appear a silly question, but why the AfterUpdate event and not the OnClick event? Just a thought.
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Populate a form based on ComboBox value (xp)

    It doesn't matter. For a combo box, the On Click and After Update events are equivalent. I tend to use After Update for consistency - it's the one you would use for a text box, for example. The On Click event of a text box occurs when the user clicks in the text box, the After Update event occurs when the user has changed the text in the text box and moves on to another control.

  5. #5
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Populate a form based on ComboBox value (xp)

    <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

Posting Permissions

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