Problem with List box query

J

Jim Pockmire

A query for a list box on a form has a parameter set by a value on another
form. Changes in the value on the form do not have an affect on the list box
query - that is until I open the form with the list box and "inspect" the
query. Then the list box query works fine. Can't figure it out.
 
D

Douglas J. Steele

Are you expecting that the listbox will change because the value on the
other form changes? It won't unless you issue a Requery for the listbox.
 
J

Jim Pockmire

...forgot to mention that I am doing a requery, which is why it is so
strange.
 
D

Douglas J. Steele

What do you mean by "'inspect' the query"? And are you sure your Requery is
firing?
 
J

Jim Pockmire

By inspect the query, I open up the form in design view and then click on
the row source property for the list box, then go back to form view and the
list box is fine.

Regarding the query firing, I've stepped through the code for the requery
and the statement is executing.

There is undoubtedly something I am overlooking.
 
D

Douglas J. Steele

While you've single-stepped through the code, does it actually fire when
expected? It's not uncommon for procedures to get "separated" from the
control whose event is suppose to fire the code.

Is the row source for your listbox SQL or the actual query?
 
J

Jim Pockmire

SQL. Your point is interesting.


Douglas J. Steele said:
While you've single-stepped through the code, does it actually fire when
expected? It's not uncommon for procedures to get "separated" from the
control whose event is suppose to fire the code.

Is the row source for your listbox SQL or the actual query?
 
J

Jim Pockmire

I may have figured it out based on your idea that code can become detached.
I have a series of forms that use the same list box and I copied the SQL
from form to form.

I have since opened up each of the forms and executed the SQL for the list
box and then saved the form - it looks like it is testing out okay.
 
D

Douglas J. Steele

Good. Copying a control is one way that the code can get separated. You need
to go into the properties of the control, and make sure that it says "[Event
Procedure]" as the property for each event that's supposed to have code. I
gave code to automate the fix in my March, 2004 "Access Answers" column in
Pinnacle Publication's "Smart Access". You can download the column (and
sample database) for free at
http://www.accessmvp.com/DJSteele/SmartAccess.html
 
Top