Autopopulate combobox based on other combobox in access - ms-access

I have a problem with two comboboxes in access. I have one where you can select the postal code and another where you can select the city. Every city is connected with a postal code. In the dropdown menu of the comboboxes is only one column visible (so in postal code you can only see the postal codes but not the cities that correspond to the postal code). Due to the fact that there is only one column visible I think it's impossible to use the
afterupdate Me.combopostalcode=Me.comboboxcity.column(...)
I tried with the DLookup function but it doesn't work. It only works if I create one combobox (for instance a combobox postal code) and a textbox city. If I change the city textbox in a combobox and write a DLookup in both comboboxes to fill in each other with the right value no value for postal code is filled in the combobox postal code if I select something in the combobox city. It also doesn't work in the opposite way if I select a postal code and want the city filled in the combobox.
I read something about cascading comboboxes but I think it's not the right solution to my problem.
Thanks in advance

Related

Split form columns not displaying correct value

I have a split form set up in Access 2007. In it, I have one combo box to select a school, and the After Update event for this combo box populates a second combo box.
The second combo box selects an item of equipment, and the query associated with it selects all equipment located at the selected school, unioned with the currently selected piece of equipment. (If the school selection changed, the box would turn blank, but actually still hold a value, so I unioned it with it's own current value)
Anyhow, the issue is that the equipment column in the split view only shows equipment values that are associated with the currently selected school as well. For example, if I have a form with schoolA and EquipmentA selected, only equipment also associated with SchoolA will appear in the Equipment column of the split form data sheet. If I change the School column to SchoolB, any rows that were populated with equipment associated with schoolA disappear, and equipment on rows associated with schoolB now show up.
Interestingly, if you click on the school column of the data sheet, this also will update the equipment column to only show equipment related to whatever school was in that row.
To summarize: changing the value of one field in my split form will change what data is displayed in the data sheet portion of the form. Clicking on the fields column in the data sheet has the same effect.
I had the same issue, as you describe. I used a workaround (i.e. used different control instead of split-form)
My Situation:since In the split-form, I was just showing the records, and not allowing users to edit the records in split form. Users could click on any record in split form, which would show in main form, and then could edit. The main purpose of this form was for the users to be able to search for the data in split form and then select and edit.
My workaround : Created a form, where I used text boxes to search, and a list view to show all the columns which were in the split form. On double click event, I added Open the form filtered with the record which was double clicked.

Microsoft Access 2007 Input Form

i am new in MS Access database and i have a problem to in insert form. I have already
created a relational database in MS Access 2007. Now i need to create forms to create a insert data.
Let me go with details,
I have two tables,
User - Columns(Id[PK],Name,Address, CountryID[foreign key ])
and
Country - Columns(CountryID[PK],Country Name)
So i need to create a input form for User table that will display the Country Names as Dropdown/select box and the data will be showed from Country table. When anyone selects a country i will save the CountryID of that country.
I have checked in googled but almost all of them stores the same value that is selected but i don't want that. In my case if a Country Name is selected then corresponding CountryID will be saved.
Thanks in advance.
pks
Right-click on your dropdown box. Select the Properties menu.
Scroll down to Row Source Type. On the right side you should see a
drop-down arrow. Click it and select "Table/Query"
Just above that you should see Row Source. All the way to the right
you should see an elipsis ("..."). Click that and select your Country
table.
Just below that you should see "Bound Column". Make sure that's set
to "1". That will bind the first column to the "Value" property.
Now, when you select a country from the dropdown, it will display the name but will have a value of the ID. So, Country.Text will be the name, Country.Value will be the ID.
Go to design view of the form. you use the Control Wizard when you add a combobox to your form, a wizard will guide you through the steps of storing the ID, but showing the Name. Go to the Design tab. Click on the Combobox icon and then click on your form. If a wizard does not start, go back and turn on Use Control Wizards on the dropdown list under the icons. On the first screen, choose I want the combo box to get the values from another table or query. Then you'll specify Table: Country. Add CountryID and CountryName. Sort by CountryName. The next screen will hide the CountryID (because it is a primary key) and just show the CountryName. Specify that you want the value to be stored in the User table's CountryID field. Specify a label and click finish.

Add new Items in a combo box in 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

Listbox Form Navigation & Record Summary in Access 2010

I'm working on a project in Access 2010 where I am creating a form with a subform. On the side of my form I have a Listbox control which I would like to update with the FirstName of person information records entered into my subform. Additionally I would like the Listbox to be clickable for easy navigation of my users so they can simply click on a persons name and have it load the record into the subform. Is there an easy way to accomplish this, or am I doomed to use VBA? If so I would really like some assistance. Sample code would be a life saver.
To provide some context, here are some sample tables:
Families (ID, LastName, HomeAddress, City, State, Zip)
People (ID, FirstName, FamilyID, Phone, Email)
Requirements:
The Listbox called "All Members" should display all family members for the current FamilyID
Should auto-update upon each newly added family member
Should load the subform upon clicking a FirstName with that person's data
Here are some pictures of the Form/Subform & select Properties to help with understanding my goals :)
For the last several hours I've been trying to find an answer for this prior to coming here. You will help me more than you know. Thank you so much to whoever can help me solve this question ;)
It is perfectly possible to do this with no coding at all. Make sure that the bound column of the listbox is FamilyID and that FamilyID is in the recordet of the subform control form (contents), then set the subform control properties like so (note: control, not contents)
Link Master Fields : NameOfListBox
Link Child Fields : FamilyID
Further Information re Comment
Recordset is not a property, it is a word that you are going to come across regularly if you continue to work with Access.
I misread your requirements, it is People.ID that needs to be the bound column so:
Listbox : FamilyMembers
Data Tab
RowSource : SELECT People.ID, People.FirstName FROM People
WHERE (((People.FamilyID)=[Forms]![Families]![ID]))
ORDER BY People.FirstName;
Bound Column : 1
Format Tab
Column Count : 2
Column Widths : 0cm;2.54cm
Subform Control
Link Master Fields : FamilyMembers
Link Child Fields : ID
Form of Subform Control
Record Source : SELECT [People].[ID], [People].[FirstName], etc FROM [People]

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.