Solved

Running query from an OnChange event on form.

Posted on 2008-10-29
5
565 Views
Last Modified: 2013-11-28
I have a for that has a drop down box and I have a qry the looks at the name that is in the drop down box and returns data based on the choice. I now need the qry to run when that box changes. How do I run a query from the OnChange Event of a field?
0
Comment
Question by:jlcannon
[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
  • 2
5 Comments
 
LVL 11

Accepted Solution

by:
SeanStrickland earned 500 total points
ID: 22831064
Is the query set as your form's recordsource?

You would use the After_Update event of the combo box generally, and the code would look like this:

Private Sub cboname_AfterUpdate()
Me.Recordsource.Requery
End Sub

Something similar to that.  I put Me.Recordsource because I'm not sure what exactly you're requerying.  However, any query that uses a combo box as part of it's criteria can be run this way, or executed with the DoCmd.OpenQuery function once the combo box has been updated (After_Update event).
0
 
LVL 77

Expert Comment

by:peter57r
ID: 22831094
I am guessing from the wording of your Q that you are not a code writer.
Therefore the simplest way to do this is to build a macro that uses the Openquery action to open your named query.
Then in the OnChange event property you can select that macro from the drop down list and it will run whenever the value changes - although you will have to close the query yourself each time, before the next run.
0
 

Author Comment

by:jlcannon
ID: 22831470
ok when I do this:
Private Sub Combo6_Change()
Me.qryReport.Requery
End Sub

I get Method or data member not found error when I change the name in the first dox.
0
 

Author Comment

by:jlcannon
ID: 22831706
Private Sub Combo6_AfterUpdate()
Me.List8.Requery
End Sub

that worked. Thanks, I just misunderstood what you meant.
0
 
LVL 11

Expert Comment

by:SeanStrickland
ID: 22833431
Great!  Glad I could help. :)
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

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.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

622 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