Full Version: Refresh Rowsource for combo box as an [EventProcedure] OnChange
UtterAccess Forums > Microsoft® Access > Access Forms
Hi an example of what i want to do is basically I have 2 combo boxes one links to films and one links to the cinema field on a query which uses the film field of the form to find which cinemas its being shown at.
That i basically want it to do is when you choose a film it will only allow you to choose a cinema it is being shown at and not any of the others..
Ooriginally thought that i could put an [Eventrocdure] on onchange for the film to somehow update the query, as it is now it works for first film chosen but does not update when a new film is chosen..
Thanks in advance.
if you want to requery the 2nd combo box and so refresh the data in it then in an after update event of the first combo box add in
Thanks alot that worked a treat frown.gif
Hi another question is there a way i can do the same but witha text box.. as i notice that code doesnt update it in realtime as far as the user can see it updates what will be there when then to arrow on box is clicked... but for a text box it would require that the field be changed straight away ... i have tried using the above code but did not work for text box.
What would the text box want to show?
How is it populated?
the text box is to show the location of the cinema which was what was updated last post. It couldbe populated from the same query as the cinema or from a ew query looking for location using cinema combo box.
Edited by: reser on Wed Oct 6 12:03:10 EDT 2004.
so is the field you want in the text box in the combo box (as one of the other columns)? If so then you can just add some code like this to the after update event of the second combo
e.textbox = me.combo2.columns(1)
When using this you need to remember that the first column in a combo box is numbered 0.
If the column is not in the combo then you can use a dlookup
=dlookup("[fieldname]","[tablename]","ID =" & me.combo2)
for more info on dlookups you can look here
Ok i done the dlookup... i done it as the control source.. is this where I should put it as im getting #Name?

am i supposed to do anything with the ID= part?
Edited by: reser on Wed Oct 6 15:55:41 EDT 2004.
The ID should be the linking field and the bound field of the combo.

You're basically filtering the table by the combo box.

If you can post a zipped up version of the DB I'll look at it for you.
Ok i tried doing ID=CID (Cinema ID) was i supposed to do it as ID= or change the word ID to the actual field? I tried both, and it still didnt seem to work ill attach db .
Here's your sample back....
ight what I did was I added the CID to the cinema combo box as the bound field (but hide it by setting the column width to 0) and added the location to the combo as well (but again hide it by setting it's column width)
Then I added on the after update code of the cinema combo
me.location = me.combo16.column(2)
That makes it quicker that doing the lookup and works...
One more point... ID's should be autonumbers...
Thanks alot working a treat frown.gif

I would of done autonumbers but this particuler task required I used the given CID and Film ID.
Edited by: reser on Thu Oct 7 20:18:32 EDT 2004.
you're welcome.
might still suggest adding te ID colume with autonumbers (the CID and filem ID can stay).
The ID autonumber is for the DB to use and should not hold any meaning to the users... they should not even see it
but I'm glad you're now working and back on track.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.