Full Version: Update combo box on record change?
UtterAccess Forums > Microsoft® Access > Access Forms
dannym
I have a combo box on a form that is used to select a record to display. It works fine, and the correct record is displayed when selected. The problem is, if the user selects another record via the data control, or any other means, the combo box displays the last record that it looked up. Is there a way to keep the cbo updated with the current record, or a way to force it empty when another record is selected? And is it just me or does Access's help files and web help stink? Many thanks for any assistance you can provide.
Danny
Jack Cowley
Access help files give new meaning to the words, 'lousy tech writers'...When you select a record via a means other than the combo box, add this code:
e.ComboboxName = Null
That will 'clear' the combo box and you should be good to go.
hth,
Jack
dannym
Jack,
Thanks for the quick reply. On what event should I place that to be sure it executes each time a record is changed? Should it be on a form event or something else?
Danny
Jack Cowley
Try the Forms On Current event and see if that works for you...
th,
Jack
dannym
That solves the problem Jack. Can't thank you enough. This is the most helpful forum I've ever used.
Thanks again my friend,
Danny
Jack Cowley
Danny -
You are most welcome and we are very glad that you are a member. Without your support, and the support of so many others, we would not be the forum that we are today. Thank you for being a member of the UA community!!
Jack
bb44
I found your posts while searching for help with a problem. My issue is similar, except that I am using the popup calendar for the date field and a combo box for a department field. They are not tied to an underlying record set - just referencing them as criteria in a query that pulls records into a subform.
When I change the date field, I want the department field to clear OR have the subform refresh. The subform is based on a query with the date and department criteria from the form.
Currently when I pick the date, then pick the department, the subforms populate. But after that, if I change the date only, the subform data does not refresh.
I Have tried

Me.ComboDeptName = Null in the date field's after update property to force the user to select the department again every time they change the date but it does not work.
Have tried a refresh also in the after update property, with no effect.
Would appreciate advice. Thanks.
Jack Cowley
Your popup calendar fills the date in the DateControl on you form. Selecting a new date from the popup does not trigger any code in the DateControl so you need to do the code in the popup calendar. I do not know what your code looks like but this may help you write the code you need:
If Not IsNull(Me.ComboDeptName) Then
Me.DateControl = Me.Calendar.Value
Me.SubformName.Form.Requery
Else
Me.DateControl = Me.Calendar.Value
End if
I have not tested this code and I am not sure if it will save the date in the DateControl before the subform requery so that is something that you will have to watch for.
hth,
Jack
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.