Question Runnng a Query from Code

music_al

Registered User.
Local time
Today, 18:53
Joined
Nov 23, 2007
Messages
200
Hi

I have a query that takes the value in a form control as its criteria...

[Forms]![frm_Work_Request]![txt_WR_ID]

A control on the main form (a list box) is populated by the query. This works fine.

When I go to the next record on the main form, I want the query to run again (I dont need to open it/see it) - I just want the list box to be refreshed.

I added a docmd.openquery command but this obviously opens the query (which I dont want) and the main form isnt being refreshed with the new query results.

Can anyone help ?
 
The list box should be refreshed if the row source is that query with the form reference, but you can specifically requery it on the form's ON CURRENT event by using:
Code:
Me.YourListBoxNameHere.Requery
and make sure you put the code in the VBA window and not in the event property dialog or else you'll get a "Access can't create the ActiveX control..." type error message.
 

Users who are viewing this thread

Back
Top Bottom