Solved

Drop-down value does not get updated

Posted on 2014-03-23
4
790 Views
Last Modified: 2014-03-23
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
Comment
Question by:sglee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 315 total points
ID: 39949147
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
 

Author Comment

by:sglee
ID: 39949177
It works like a charm!
Why was it necessary to re-query Combo111?
0
 
LVL 37

Expert Comment

by:PatHartman
ID: 39949198
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
 

Author Comment

by:sglee
ID: 39949206
Thanks.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question