Form to edit table selected from combobox - ms-access

I have several (many, 30+) tables of values ready for use in comboboxes on various forms. I want users to be able to add values to these tables in case they need an additional value while filling out a form, but I do not want to create 30+ identical forms (one for each table) to make edits. So, I have a form where I can select one of the tables from a combobox and then open another continuous form that will eventually be used to show and edit the values in the table I selected. What I can't figure out is how to link the continuous form text fields to the table I selected in the previous form. I need to be able to set the textBox control source to something like [Tables]![[Forms]![FormToSelectWhichTableToEdit]![Combo0]]![DropdownValues], but I have the wrong syntax or something.

Related

Checkbox per row in multi user access database

I have the following situation:
I have a many to many relationship.
For example an Employee Table, an Course table, and an relation-table inbetween.
Now I want that the user can select out of the course table his courses in a dialog form.
That means that the underlying table for my continous form inside the dialog is the course table.
I want a checkbox in every row which indicates if the course is selected or not.
As I read it is not possible, to add an unbound checkbox, because they are just copies, and a select click would select all of them.
The solution would be to add an yes/no field to the underlying table courses.
But here I have the problem as I understand the matter, because I have several users using the database at the same time, that the underlying table will be updated if I click one checkbox and this update will select the value for all users which are using the dialog form concurrently, what I dont want.
So my question is, is there another solution to get a working checkbox per row in a multi user access database.
There are two solutions which I could imagine:
1) The underlying table will be the relation table and in this every possible combination between employee and course will be saved together with a yes/no field. (but that would be from a data view point quite horrible)
2) If the changes to a checkbox would not be directly written back to the database table, I could discard them on saving and manually insert the relation records in the relation table. (Is that possible?)
Thanks for any solution proposals
I see two good approaches:
1) This assumes that your database is split in a network backend + each user has a local frontend. This is the recommended setup for multi-user.
The frontend has a local table with Course_ID and a yes/no column.
A join of this local table with the Course table is the recordsource for your continuous form.
On loading, you copy the course ids into the local table, and set the existing relations to True.
On saving, you update the relation table.
2) Use a ListView control instead of a continuous form. It has inbuilt checkboxes. Loading and saving is done with a VBA loop.
Based on your description I assume your form has a LEFT/RIGHT JOIN in its data source where some ID field is null if the specific Course/Employee combination does not exists in your relation table. Let's call it LinkID. Then your checkbox should be something like =NOT ISNULL(LinkID). While you will not be able to use the OnClick event for the user to check/uncheck this way, you can use the onMouseDown event to see if the user clicked the checkbox and take action accordingly.
That way you don't need an "all combinations" relations table, no temporary table and no Yes/No field. If a record with the Course/Employee combination exists the box is checked, if it does not exists, it is not checked. Adding and removing courses is done by adding and deleting records from the relation table.
Have a look at this How to use unbound checkbox in a Continuous Subform - MS Access. A class that binds an unbound checkbox. Better than listbox, because you have a form with all its benefits (sort, filter, edit, append).

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.

MS Access: update whole table from form

I have a small table 2*2. I show the values of the form in a continues form. Suppose, it show the values in the form as below
fname lname
----- ------
adam jones
terry jonas
For simplicity I kept the table size small. But basically it is 10*10 size table. Anyway, what I want is that, the names that show on the form should be editable. So after showing the form above, I should be able to edit all the names adam, jones, terry, jonas. After editing the names, if user click on update button then all the names in the database table should be updated.
I don't understand how to do this. This is a continuous form. How can I keep track which names are being changed on the form? Or should I update the whole table? Or if I make it single form without being continuous will it help? Please give me some insight so that I know how to proceed.
A continuous form is by definition a bound form, i.e. it is directly connected to a table or query. If you edit a row, and move to another row, or close the form etc., the edited record is saved automatically.
This is standard Access functionality, and you don't need any code (or a "Update" button) for it.
If you want to have more control over the saving of records, you need a different approach. But you should have a real reason for it, otherwise you are just creating useless code.
E.g. you can make the continuous form read-only, and on double-click open an unbound single form that loads the values of the current row, and is editable. There you can have a "Update" button that saves the values to the table, and a "Cancel" button that discards the changes.
Or if you want to edit on the continuous form, you can copy the whole table to a temporary table, base your edit form on that, and on "Update" copy the temporary table back to the actual table.

textbox in continuous form populated from different table

I have a continuous form in an access 2010 database that outputs a separate row of data for each customer from a customers_table. The continuous form is for data display only, and no data entry or editing is allowed. One of the textboxes on the continuous form is populated with data that was entered using a combobox in a different form used for data entry. In the textbox on the continuous form, enabled is set to no, and locked is set to yes, so that the textbox is not editable in the continuous form. However, in the separate data entry form, the combobox entered the id for the selection the user chose, instead of entering the text. Therefore, in the continuous form, only an id number is shown, when the user needs to see the text of the specific option which is encoded in that id number.
I think I want to keep the id in the customers data table, in order to retain freedom to make subtle changes in the combobox options later.
So how do I modify the textbox in the continuous form to populate with the textual value associated with the id number? This would seem to involve some sort of SQL like:
"Select textValue FROM comboboxsource_table WHERE comboboxsource_table.ID=textbox.Text"
However, I have no idea where to put this in the Access GUI. The Control Source field in the Data tab of the property sheet for the textbox does not seem to allow this sort of syntax.
If you're not editing the data, put a query behind the form instead of a table. Then, just pull the field you need into the query and VOILA! Problem solved. :o)

how to create a filter form for a Microsoft Access Report

I am fairly new to Access. I am trying to create a filter pre-report form. On this form, the user will be asked for a start and end date. He will also be given a list of Item names which are found in a different form/table and will have the ability to check off which items the report should filter on.
Do I need to use a subform for this? I tried one out, but I can't see how to add checkboxes, it seems to just give me a list and I can't modify the subform.
What I really think I need to do is to populate a checkbox list with all of the items in the other table. How exactly would I do this (if its really the best solution)?
You can use a regular form for this. You do not need to bind it to a table. Just drop 2 textboxes on the form, and as many checkboxes as you feel you need.
The report will be based on a query, which in turn will be based on this form. All the fields will be brought into the query and will reference the controls on the form.
For instance, let's say you have 2 textboxes on the form; one called txtStartDate and one called txtEndDate. The form will be called frmReportFilter. In the query that's driving the report, pull in your date column and in the Criteria put >=Forms!frmReportFilter!txtStartDate. This will pull in all records where your date field is greater than or equal to whatever is in the Start Date textbox. The rest will be referenced similarly.