Updating Unbound combo box value lists - ms-access

I have a database that allows an end user to search all available records in a table based on the criteria they have entered. I have a form with three command buttons (search, clear, and close), six unbound text or combo boxes, and a query. When the user enters data into the text or combo boxes they will click the search button and the query will use the users data to search the table for the results. All of this works great. My problem is…. The combo boxes are value lists. When I add new values to the list, all bound fields update automatically, but the unbound do not. Is there a way for me to automatically update those unbound fields when I update the bound ones too? My code for the search button is below if anyone has any pointers or thinks something needs changed.
The record source for the bound comboboxes is empty but has a control source from the table (manufacturer combo's control source is the manufacturer field of the table and the main form is bound to the table). The Unbound combo box has a value list record source and the form is unbound. If I bind the form to the table and the control source of the combo to the correct field of the table When I select a manufacturer as my search criteria it changes the records to that manufacturer instead of just finding all the records that match the criteria.
If DCount("*", "User Customer Owned Parts Query") = 0 Then
MsgBox "No Records Found"
Else
Me.User_Customer_Owned_Parts_Query_Subform.Requery
End If

Related

MS Access get number of sub rows in datasheet

I have a little problem here. I've a database with one table for Users and one for changes in progress for these users. They are in a 1:n relationship (one user can have many changes but one change only affects one user).
I output my users in datasheet view and have the changes in by standard collapsed subrows of this datasheet. The user shall be able to order the users by the number of ongoing changes matching the filters in this sub-form. Therefore i have to get the number of rows in this form.
in the subform i have a field called "Anzahl" (german for count) representing the number of elements currently shown in the sub-form and i have a field called SubFormAnzahl in the parent datasheet.
Now i try to access this field via
=[Changes_Subfrom].[Form].[Anzahl]
and i am getting a #Name? error.
Why does this happen and how can i prevent it?
With main form set as datasheet, it can't see subform textbox until subdatasheet is expanded, then the calc shows. If you want to keep main form as datasheet, options are:
set main form SubdatasheetExpanded property to yes.
DCount() domain aggregate function on main form - expression in query used as RecordSource or in textbox and must use same filter criteria applied to subform
DCount("*", "Changes", "UserID=" & [ID])
Otherwise, works with main form in Single view.

Access: insert multiselect box values into database

I have a form setup in Access that contains many input fields and dropdown boxes.
This form doesnt contain an insert button. I just click on 'add record' at the bottom of the window.
Now I`ve add a multiselect box which contains multiple values.
I want the form to insert the selected values from the multiselect box along with all values from the other input fields in the same row if possible.
For example; the column that holds the multiselectbox values needs to contain 1,2,3
Another option is to store these values in a different table as long as I can join both tables when generating reports later on.
Any pointers are appreciated
You have two options. Either way requires a table structure like this (called a many-to-many relationship):
Option 1 is to make a subform which has a combobox on it. The subform is bound to this cross reference table ParentTableLookups and the combobox's control source is ParentTableLookups.LookupStoreValue and Rowsource is the Lookups table.
This is much less code and doesn't require a save button however it does mean that in order to see the things a user did not select they need to open the combobox. Maybe not quite as visually complete as the listbox.
Option 2 is to use the same table structure but instead of a subform you fill in a listbox on your parent form from Lookups. Then you iterate over ParentTableLookups where ParentTableLookups.ParentTableId = your current record and for each ParentTableLookups.LookupStoreValue you select that in the listbox.
In the parent form's AfterUpdate and AfterInsert records you need to repopulate ParentTableLookups based on the selected listbox values. You can create the records using DAO easily.

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.

how to display specific records for editing in MS Access

I need to display certain record (all the fields in the form populated according to that record in the form) according to textbox in form. Is there a way for me display that record without using filter or vb code? Do i need to design a query for this?
Yes you can put an unbound textbox (or combobox) in the header of the form. Then change the recordsource of the form to a query, just click the elipsis (...) next to the table name in the record source property and access will open the query design window for you.
You need to add all the fields to the query and in the Criteria row of the field you want to select by right click with the mouse and select "Build". You will be able to select the unbound textbox.

MS Access: Update a Linked List Box

I have a list box on an MS Access 2010 form that has its contents generated by a query. The list box lists new customer names; these names are the ones that are not listed in the Customers table in the DB.
The user can select a customer name on the list box and click a button to add that customer name to the Customers table.
Now, after the new customer is added to the Customers table, I want to refresh the table, i.e. I want to re-run the query that generates its contents. Is there a way to do this in VBA or by setting a property?
Thanks! :)
Listboxes, comboboxes, and forms/subforms have a Requery method that should refresh/requery/reload the underlying recordset.
Me.Requery 'Requery Form
Me.Listbox1.Requery 'Requery Listbox
Me.ComboBox1.Requery 'Requery ComboBox
Me.SubformControlName.Form.Requery 'Requery a subform
Choose the correct one above and change it to match the name of your control. I think you should put it at the end of your code on your button_click() procedure. In some scenarios you will place this code on a control's AfterUpdate event.