473,386 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Adding data in combo boxes

I have a combo box that is pulling data out of table that I created with possible selections for the users of the database. I also have another table where the data is saved after the user has completed the form. My question is...I cannot restrict the users to the options I came up with in the table, so how do I set up the combo box so that users can either select from the existing list, or add an item and have it saved to the list for subsequent users?

I created an append query that does this, but I don't know how to make the query run automatically, every time a new item is added. I've seen some postings on the AddItem property, but I haven't seen how the code works.

Any help would be greatly appreciated!
Sep 5 '06 #1
4 3378
comteck
179 100+
There is a property for the combo box called "Limit to List". Set it to "No".

comteck
Sep 5 '06 #2
PEB
1,418 Expert 1GB
Hi,

If you want to Save every introduced value in the combo box in the after update property you have to assign a Macro that runs your Query!

For your Macro You can use RunsSQL Macro and copy your SQL from your query to your Macro!

So in this case you don't have to write a code and you will use only Macros and SQL :)
Sep 6 '06 #3
Well the SQL did what I wanted it to do, but the Append query is not the way to go. First of all, it adds duplicate entries to my table. I know there's a way to prevent this, but the major issue, is that I want the new option to appear in the combo box as well as in the table when it is saved, and the append query only saves the options to my table.

Is the AddItem the way to go? and if so how does the code work?
Sep 6 '06 #4
PEB
1,418 Expert 1GB
To escape from the repetitive add of items you have to change your Append query. I'll give an exemple how to do it!

1. You have to create a table for exemple Connection
2. In this table yu insert only one record! The information for this record doesn't matter! The columns of this table also doesn't matter!
3. Imagine that you save the New Values in a table COMMUNES in the filed COMMUNE and the new value is "ARBIGNY"
So your SQL should seems like:

INSERT INTO COMMUNES ( COMMUNE )
SELECT "ARBIGNY" AS Expr1
FROM [Connection]
WHERE ((("ARBIGNY") Not In (SELECT COMMUNE FROM COMMUNES)));

In this SQL you have to change "ARBIGNY" with your Form Control and change the table Names and fields

So you shouldn't have a dublicates in your table!

When you want that the new value appears in the combo box you should refresh or requery the combo box or the form!

So to do this you have to replace the macro in after update with event procedure

your procedure is:

DoCmd.RunMacro "Your macro name"
Me!ComboBox.Requery
Sep 7 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Paul Edwards | last post by:
I am writing in c# with Visual Studio 2003. I am creating a form that shows one record from a Dataset that is populated with only one record from SQL Server 2000. I am using bound controls, both...
6
by: Robin S. | last post by:
**Eric and Salad - thank you both for the polite kick in the butt. I hope I've done a better job of explaining myself below. I am trying to produce a form to add products to a table (new...
1
by: edworboys | last post by:
I have a form (Prospect) with a subform (Document). The result I am looking for is this: The user selects a prospect which is made up of Prospect Name, Country, Company and Prospect Type. They...
3
by: MS | last post by:
What's the best way to "store" and display a value in a text box that changes from day to day. An example of this would be where the name of the user is manually typed in after using the datbase,...
1
by: Shawn Yates | last post by:
It has been a while since I have done anything on MS Access and I seem to be a bit rusty. I hope someone could help me solve my issue. I have a form that has multiple combo boxes on it. Each box...
5
by: consonanza | last post by:
I am working on a report filter form. It has 2 combo boxes (cmboSelectSubject and cmboSelectCategory) to select criteria. Selecting an entry in combo 1 restricts the options available in combo 2....
6
by: ljungers | last post by:
Hi to all and hope someone may have an answer for me. I have a Form named Cust_lukup_Form that has 3 text boxes and a click button that uses a OnClick to call Cust_lukup_Macro that runs an...
0
by: chixor1 | last post by:
Good afternoon All I have got over some hurdles on my current project and now I am stuck again. Im now having issues with writing the code that takes the calculations from my txt boxes and inserts...
3
by: =?Utf-8?B?Y2RtdW5veg==?= | last post by:
I have created a sub routine to programmatically add an indefinite number of combo boxes to a form. The combo boxes are bound in code to a view for displaying the available options. This routine...
11
by: jgoodnight | last post by:
Hi, I have a form with three combo boxes: Area, Sub-Area, and Factor. I've set up the Sub-Area combo box to list only those areas that are part of the selected area. I've set up the Factor combo...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.