Add new Items in a combo box in access - ms-access

im new to access 2007
I have 3 tables and One Form..i have Accounts,IT and Software tables..i have created each table and enter a values for them(ID,Description).. i have another table called Faculty which i have the AccountsID,AccountsDesc,ITDesc and SoftwareDesc as attributes in my combo box form.So when i did my Query all working fine.even if Accounts Desc start with first character as 'F' it able to pick it up..because Finance was already entered in my database..My Question i want to add a new Accounts Name on the combo box without add from the database?..so that it can be saved in my drop down list if its selected again.. i try many ways but i cant..anyone can solve my problems?..

You can only have your combo list come automatically from a table, or by entering it manually into a value list. You can't do both.
So, to solve your problem, you'll have to use VBA. I'm just going to give you the rough steps here. You'll be ale to search for details if you don't know how to do a step.
In the Form_Load event, you'll build your list.
You'll do this by opening the table or query that has the values you want in your list, reading it one record at a time, and entering the value into your combo box.
The command for adding an item to the combobox is ComboboxName.AddItem value.
Then add your additional value you want. ComboboxName.AddItem "New Account"
Good luck

Related

Issue w/ Cascading Combo Boxes deleting field values from records they pull from for Form

My apologies if this question has been answered before but I've searched all day today and haven't been able to find the answer I seek. I'm building a database for requesters to submit requests to order paint using combo boxes that pull from a PaintCatalog table, broken down by ProductName, ProductColor, Nomenclature, UI, StockNumber, DuplFieldCd (I use this a unique key for paints with the same product name but come in multiple colors and Units of Issue.) I've been trying to set up a form to pull the data into cascading combo boxes from this PaintCatalog, with each selection reducing the dropdown choices until it reaches only 1 choice, at which point it autofills specific fields. Then the user clicks a command button and the values in the form fields are used to create a new record in the PaintRequests table. I've got most of that to work, however when I delete values from form's combo box fields when I'm retesting the form, one of the records in the PaintCatalog starts to get blank values. I need this issue fixed before I can progress any further. I've tried using a query instead of referencing the table directly, but the data is still getting edit, deleted, or overwritten. I'm getting that pencil icon every time I'm using one of the form combo box fields. Please advise.

How to get combo box selection to fill related fields with data

I have a table [inventory] with inventory items, and a bunch of columns with different information for those. Mainly, part#, description, price. I am trying to create both a purchase order form [POForm] and, and a inventory transactions form [TransactionsForm], but that one thing I've been stuck on is getting a combo box look up I use to select the part# from [inventory], to also fill my fields for description, and price for that item in my form. I need the fields that are filled to be able to have formula's run off of them, and the information to be saved into the table for that form [TransactionsTable], [POTable].
I've tried making my part# combo box include the fields for the description and price, and using =[part#].[column](x) in the other fields as a lookup, and it looks right visually, but that is apparently just a visual of that data, but technically the field is still blank, because those other fields remain empty in the table for that form, and I am not able to run a formula off the price.
As per my understanding and please correct me if I am wrong. you have a form that shows your inventory data Part# Description & price. This form has a combo box that allows you to select a particular part # to view its related record data description and price.
Now you want to click a command button after selecting a particular part # to update your transaction form and POtable.
1.you have to create a query,
2.insert the inventory table in it
3.select append from the query type in the ms access ribbon
4.a window will appear, choose the transaction table as the destination table to append to.
5.double click on the fields that you want to retrieve its data from the inventory table
6.then in the table below in the query itself in the "append to" row you will find drop-down menu including all the fields from the transaction table. choose the corresponding fields. note if the fields have the same name in both tables access will do it automatically.
7.in the criteria row type the following [Forms]![Inventory Form Name]![the name of the field in the form]. do that for each field in the happen query.
8.save the query and name it
9.go-to design view in your inventory form and create a command button, in the click on event creat macro of the following: openquery-->type the append query name
10.save and close macro builder
11.open your form, select part#, click on the button
12.access will ask you to confirm appending process. click ok/yes
13.check your transaction table to confirm that the append process was successfully performed
14.Tip if you do not want the confirmation msg of append to appear, in the click on event go to the macro builder and choose in the ribbon show all actions then in the first line of the macro builder insert setwarnings - NO
the same is to be applied for the POtable.
Anyways, I hope you find this clear and helpful but I have only one concern you do not have to append part description and price in transaction and PO tables as you already have this data in your database in the inventory table. Generally speaking no need to include the same information in multiple tables otherwise you are not benefitting from the idea of a relational database.
I hope I addressed your inquiry.

How to implement multi-select?

First of all, I need to say that I never worked with Access or any other databases before. I'm trying to understand how it works and picked "Students" template for this task (see step 0). Now, let's start.
i. Creating the base from the template and fill it with data
Step 0. Creating new database based on "Students" template:
Step 1. On the objects pane (i.e. left sidebar) search for Student List form and double-click on it:
Fill the First Name and Last Name for the first student: it will be Mike Smith.
In the Special Circumstances column it is possible to select multiple circumstances: for example, Circumstance 1 and Circumstance 2. And if you click on the icon below the combo-box, it is possible to edit the list of available check-boxes:
Step 2. After we have created the entry for the first student, double-click on the Guardian List form and create entries for 3 guardians: Jane Roe, John Doe and Jill Joe.
Step 3. Return to the Student List form. Click on the Open cell in front of Mike Smith. It will be opened Student details form for this student. When it will be opened, click on Guardian Information tab - and you will see, that all 3 guardians are available for combo-box:
ii. Now, my task
I want to see the guardians directly in the Student List form - the same way as Special Circumstances located.
I want to get the option to select multiple guardians for each student - the same way as Special Circumstances check-boxes are implemented.
iii. How it was solved myself, but only the 1st point of the task
To simplify the task, I will use Student ID column (located on the Student List form), instead of creating new column.
On the left sidebar - click on Student List form with right mouse button and then select Design View. When Design View will be opened, select Student ID field, right click on it, then click Change To and Combo Box:
Then, on the right sidebar select Data tab, set curson inside Row Source field and then click small ellipsis (...). In the Show Table window select Guardians and then click Add button and close this small window.
Then, in the large window, do this:
And then click Save As and Close on the ribbon.
Then, switch the Student List form back to the Layout view (the same way, as we switched it early to Design View). And you will see that the first point of my task is solved: the last names of guardians are available in Student ID column:
But how I can implement multiselect, the same way as it is implemented in Special Circumstances column? So, Mike could have both Jane Roe and John Doe as his guardians.
Multi-valued combo boxes are very odd controls. Avoid them whenever possible.
Creating an unbound multi-valued combo box is not possible (see How can I create a Multiple Value Combo box on an Unbound Form). A combo box is multi-valued when the field it is bound to is multi-valued, or when it's set to a multi-valued lookup.
To change a field to a multi-valued field, you need to alter the table design, and set the Allow multiple values property to Yes:
This will automatically change any combo boxes bound to this field to multi-valued combo boxes.
Note that I highly recommend not using this approach. This database already demonstrates a junction table, the recommended way to manage many-to-many relationships. Using junction tables and multi-valued combo boxes is not possible without using very hacky techniques.

How to look up values from a table in Access

I have an Access database that is used to store basic info in a table such as first and last name. How would I go about adding the functionality to lookup by last name?
Is there a way to type in the last name and then hit like F12 or something like this? Can someone please point me in the right direction or provide me a link?
SELECT tblPatient.LName AS [Last], tblPatient.FName AS [First]
FROM tblPatient
WHERE (((tblPatient.LName)=[Enter Last Name]));
How do I tie this into my form now?
I'd suggest you create a form, with a textbox 'search' at the top, then either a listbox or subform below to display results.
The listbox record source would be:
SELECT tblPatient.LName, tblPatient.FName
FROM tblPatient
WHERE tblPatient.LName LIKE Forms!myForm!search & '*';
You can either add a Search button, which requeries the listbox, or do the requery via the Change event of the search textbox. The later may be slow if you have a large number of records; if that's the case, you could check that at least 3 (?) characters have been entered before calling the requery.
You just need to create a query in which you put =[?] as the "last name" value.
When you open that view, you'll be asked to type in a lookup value for that field.
Not sure if this is what you are trying to archieve, though...
This is probably a bit overkill for what you want to do, but I assume that you want to perform a search by last name. You should be able to glean the information you need from this article:
Build a search criteria form
http://www.everythingaccess.com/tutorials.asp?ID=Build-a-search-criteria-form
You can create queries in Access if the user you're targeting with the searchability has Access themselves.
From the main Access UI (assuming Access 2007), go to the Create tab and then select the "Query Wizard." Here is an article on the subject.
Otherwise you can create a program and connect to the MDB/ACCDB file running the query programmatically.
Seeing you wish to look up a name and populate the form based on the name selected, I suggest you need a combobox. There is even a wizard for doing exactly what you want. To start, you will need a form bound to a table or query, that is a form with a Record Source.
Add a combobox to your form
Select :
Find a record on my form based on the value I select in my combobox
Select the ID (primary key), Last and First name fields.
Access will display an example, suggesting that you hide the Key (id) column. Accept this.
Choose a name and finish.
There are a few other small things that could be done for neatness, but you will end up with a form that find the record you want. In addition, the combo will autocomplete if you type in a few letter.
If this is an mde, which your subsequent post seems to suggest it is, there is little you can do wuth out the original file. However, you could try opening the database while keeping the shift key held down and see if that allows you to edit. If you cannot get the original and the shift does not work, you could try rescuing the data, if it, too, is stored in this file.

How can I create a Multiple Value Combo box on an Unbound Form

I need your help on MS Access 2007.
I have a big problem with my MS Access Unbound Form.
How can I create a combo box i do not want bound to a table, show a multiple value List?
The Combo is named Sector and want these values to be selected in Multiples 9Which should be possible in Access 2007) from the Drop Down List: Fertilizer, Seeds, Pesticides, Veterinary products, Animal Feed, General.
Which Select Statement or VBA code can I use. I need a solution to handle this please.
Precisely a ListBox control will help you. Since you are using it in MS Access - it makes it much easier with the wizard where you can type the items list. Or if you want to use VBA, then you can load the list using AddItem property of ListBox control in the Form_Load event.
Here is one way of doing what you want:
Open up the table your Form will use. Then: Datasheet view, Datasheet Tab, Lookup Column. Select option: I will type in ... Next Under Col1 enter one of the user choices you want; for example
A Dogs, then under that enter another choice; for example B Cats, etc Next give your lookup column label a name or stay with the default. Finally, Check Allow Multiple Values box. Finish.
You now have a table with a combo box that allows the user to select 0, 1 or many choices.
But you want it on a Form.
Create Tab, Click Form. You now have a Form that has a multi value combobox.
But you want it on a form you already created.
Right click the ComboBox. Copy. Close the table and open the form you want the ComboBox to be a part of.
Right click on a clean part of the form and Paste.
Hope this is what you were looking for.