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!

I'm back! Need more help, COmbo Boxes

Status
Not open for further replies.

slammer14

IS-IT--Management
Jun 27, 2001
40
CA
Ok I have a combo box that I would like it to keep the entries the user inputs for example...

City Combo Box: They add Nanaimo to the list. How can I get it to stay so the next Form it is already there?

Also, another combo box Question

How Can I get the Combo Box, to Bring Up the Name of a Company already in the Combo Box so it is spelled exactly the same???

ANy help would be gratefully accepted.

Mich :)

 
Hi Mich,

First question: Where does the combo box get its data from? You will need to update the source of that data with the new city. When you load the combo box, the city that was added will be in the list.

I don't understand your second question. Please clarify and I'll try to help you. dz
dzaccess@yahoo.com
 
OK MAybe I am not using the correct control or maybe I need to add a piece of code.

Ok I have added 5 names of cities. However if I want a new city, how do I get it to stay in the list after I use it once. So that if another company is in that City I can choose it.

Ok FOr my other question, OK say Now that I want to add the same company but with a seperate department, however I want to make sure for Example, Painters Lodge comes out on the Next Form as Painters Lodge and be able to elimidate some Possibilities of MIspells or Punctuation errors.

Hope this makes sense :S

Hope you can help me, thanks for responding.

Mich
 
slammer, what FoxPro is asking is WHERE does the list of Cities in the comboBox list come from - NOT WHAT is in the list. You see there is a way to 'hard code' a list into the RowSource of a combo box ( With the RowSourceType = ValueList ). This approach is fine if the list is unlikely to change.

However, professional Access developers such as FoxPro and I will supply the RowSource data from a Table ( With RowSourceType = Table/Query ).
This makes Adding and Removing data from the list much easier. It can be done in code using the combo box's NotInList event procedure. You can also give the database administrator a form that will allow them direct access to adding or deleting records from the source table. ( You cannot do this with Value lists. )

Before we answer your question, therefore, we need to know which type of problem we are dealing with.


As for your second question.
This is a data structure issue for the "Tables and Relationships" board.
The Company name needs to be in one table and the Department data in another table.
Link the tblCompany to the tblDepartment in a One-to-Many relationship by having a CompanyRef Foreign Key field in tblDepartment that contains the CompanyId data from tblCompany.

Then, to add a new department to an existing company is as easy as copying the Id to the Ref and filling in the departmental information.


'ope-that-'elps.

G LS
 
OK The list is going to change alot. So I see what you are saying. And it makes complete sense. I put the values in myself, however I like the way you suggested.

So if I am understanding you correctly,
you are saying to use the cities field from my client table?
As my Row Source Type?

Please tell me if i am correct?

MIch
 
Mich,

G LS explained very well why I asked for the source of your data. I didn't know that you had typed in a Value list. Like G LS said, Value lists are good for populating simple combo boxes that display data that will never change. For example, let's say that you create a Search Form that contains a combo box that allows users to specify the search direction. The only possible choices are Up, Down, and All, so you could create a Value list with those three choices.

Based on your description, you should populate the combo box from a table or query since the data is dynamic. In other words, there's a good chance that the user will add and delete cities from the table; therefore, you don't want to hard-code a Value list that contains the city names. To populate the combo box from a table or query, set the Rowsource type to Table/Query and the Rowsource to the name of the table or query that contains the city field that you want to display. You can also store an SQL statement in the Rowsource instead of a query name.

You can set the RowSource in the Property Sheet or in VB. If you set it in the Property Sheet, store the following in the RowSource Property:

Select Distinct City From tblname;

Note that in this case, the SQL statement should not be enclosed in quotes. Doing so will cause an error.

To set the RowSource in VB, do the following:

cmbBox.RowSource = "Select Distinct City From tblname;"

Note that the SQL statement must be enclosed in quotes in this case.

You should pull the cities from the table that contains all the cities that you want to display. You haven't provided enough information to determine if that is your client table, or another table.
dz
dzaccess@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top