tags:

views:

27

answers:

2

I have a combo box with a row source based on an SQL query about like

SELECT DISTINCT Database_New.ASEC 
FROM Database_New 
WHERE Database_New.Date>= DateSerial([cboYear], 1, 1)  
      And Database_New.Date<= DateSerial([cboYear], 12, 31); 

the trouble is that if I change the value of cboYear, the values in the drop down cboASEC do not update. I have to open the query, save it and close it to get the thing to update while I have the form open. Is there a way to get the cboASEC to update somehow? maybe a little tidbit of code in the cboYear - afterupdate?

A: 

How about:

 Me.cboASEC.Requery
Remou
A: 

The expression service needs to know where to find cboYear. So tell it where to find cboYear.

Forms!YourFormName!cboYear

Then, in the after update event of cboYear, tell the form to requery your other combo box control.

Me.cboASEC.Requery

This question seems like a near duplicate of your earlier question. Maybe you should remove one.

HansUp
Not sure where you were going with the Forms!YourFormName!cboYear but the last part was good.And, yes, all of the questions look very similar, but each one is about a slightly different step in the process. Never gone this far into the row source before.
@primus Copy your SQL into SQL View of a new Access query, then try to run it. I expect it to ask you for a value for cboYear. The reason that happens is because the expression service doesn't know about cboYear, so assumes it's a parameter. OTOH, if you qualify it as Forms!YourFormName!cboYear, the expression service can find cboYear (as long as the form is open).
HansUp