Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 803
  • Last Modified:

Drop-down value does not get updated

Budget Year SelectionBudget Account Selection Query based on BudgetYear variableHi,
  I have a custom Microsoft Access program to handle budget spending.
  In that program, I have a drop-down box for users to pick the budget year and it is NOT tied to a field in the table. It is a variable on the form. I am just using it in the query that is run when user clicks on "Select Account" drop-down menu (see the query screenshots above).

After I choose any budget year from "Select Budget Year" drop-down and click "Select Account" drop-down, it displays budget account numbers that belong to currently selected budget year in the "Select Budget Year" drop-down.
However If I change the budget year in the "Select Budget Year" drop-down and click  "Select Account" drop-down, then it still displays old budget year account information.

 In other word, my query does NOT grab newly changed value from  "Select Budget Year" drop-down. I think it is because it is a variable on the form, not tied to actual field on the table.

 How do I fix that so that every user selects different year, it will be reflected in my query.

Here are control names:
Select Budget Year Drop-Down: VarBudgetYear1
Select Account Drop-Down: Combo111

Thanks.
0
sglee
Asked:
sglee
  • 2
1 Solution
 
mbizupCommented:
You need to add code to the After Update event of the Budget Year drop-down:

Private Sub VarBudgetYear1_AfterUpdate()
    Me.Combo111.Requery
End Sub

Open in new window

0
 
sgleeAuthor Commented:
It works like a charm!
Why was it necessary to re-query Combo111?
0
 
PatHartmanCommented:
When the form loads, the recordsets to populate the form and combos are created in memory.  To get a different set of data, you must rerun the query and that is what .Requery is doing.
0
 
sgleeAuthor Commented:
Thanks.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now