Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating Combo Box

Status
Not open for further replies.

spencern

Programmer
Dec 20, 2001
78
US
Hello,
I'm working on a db that is medical related and I'm having a hard time figuring out how to update a combo box on a form.
On the add patient form is a combo box showing doctor names. You select the patients doctor from the list. If the doctor is not in the list I have an add doctor button that opens a small form for doctor name and address etc. I would like the combo box to refresh with the new doctor after the form to add the doctor is closed. Is there any simple way to do this? Any not so simple way?

It would also be ok if I could just update the combo box and make the user select the new doctor.

Thanks for any ideas you have,
Spencer
 
In the add doctor form, in the on close event add this line of code:
forms!YourFormName!YourComboBox.requery

Just change the "YourFormName" to the name of the form with the combobox and change "YourComboBox" to the name of your combo box.

HTH,
Eric
 
In the properties of a combo box are the two properties that relulate what is shown in the box. The row source type and the row source. There are three choices in the type - value list, query/table , and field list - I think.

Set it to query/table and then you can construct a query

SQL = "SELECT * FROM MyTable WHERE [ID] > 1000;"

this assumes there is a field named ID and it is an integer or long.

me.combo0.rowsource = SQL

will put the defined recordset in the combo box.

Now all you have to do is requery.

me.combo0.requery

Voile' it is "UPDATED"

Is this what you are after???


rollie@bwsys.net
 
Thanks luceze,
I put the following code in the on close event in the code builder: forms!Add/Edit Customers!Combo89.requery
It doesn't like the form name and it doesn't work when I put quotes around the form name either. It says
expected: =

Just to make sure I'm on the right page, I should be putting the name of the form that is shown in the main access window, correct?

Thanks for your help,
Spencer
 
Spencer,

The form name should be your main form name that contains the combo box that needs to be updated. I don't know if the slash is causing the problem. I would recommend renaming the form without the slash.

HTH,
Eric
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top