Updating a Combo Box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a combo box that has a list of report names. My problem is that when
someone clicks on the "add a new report" button and types the report name
into the "report name" field, the combo box of report names does not get
updated with the new report name the user just typed in. I would like the
combo box to be updated as soon as the user tabs out of the report name field
where they are typing in. If anyone needs more information or I am being
unclear just let me know. Thanks for any help in advance.
 
Look at this link how you can add values to the combo using the Not In List
event.
You don't need another text box

How to use the Microsoft Access Not In List event of a combo box:
http://www.databasedev.co.uk/not_in_list.html

*************************
If you still want to use the text box, use the OnExit event of the text box
to refresh the data in the ComboBox

Me.[ComboName].Requery
 
Read up on the events NotInList and AfterUpdate.

How was your combo box filled in the first place?
A) Is it a value list filled by you?
- In the afterupdate event, do:
cboCOMBOBOX.RowSource = cboCOMBOBOX.RowSource & ";" & strNewValue
- Also consider "Allow Value List Edits" if you're working with Access
2007.
B) Is it a value list filled by VBA code?
- Call the code again in the afterupdate event to reset it
C) Is it a query?
- In the afterupdate event do:
cboCOMBOBOX.Requery

Hope that helps,
~J

PS. Code for option B would look like:

Dim rpt As Variant
cboCOMBOBOX.RowSource = ""
For Each rpt In CurrentProject.AllReports
cboCOMBOBOX.RowSource = cboCOMBOBOX.RowSource & """" & rpt.Name &
""";"
Next rpt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top