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
Solved

Running query from an OnChange event on form.

Posted on 2008-10-29
5
513 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
  • 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

856 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