Access: a Form with 2 subforms (Same table) - ms-access

I am trying to create a Form of Payments, and I want to split the actives and pasives with two subforms.
I have made it, and works! The table Payments store the values.
The actives and pasives are in a table.
ID -> Number
Description -> String
Pasive -> True/false
I have created two Forms, for actives and pasives. Each form displays the corresponding values.
Also I have created main Form that contains two subforms (actives and pasives)
When I insert a Payment
GREAT! It works!
But, when I open again the form, the values are disordered.
Can you help me?
Thanks!

I'm not sure if it understand you correctly. It looks like your subforms don't know which data is passive and which is active. Try this:
Instead of yes/no field in your table, you could rather create field with dropdown list that allows you to pick one of two values: passive or active. Let's name that field: transactionType.
Then you should add transactionType control to each subform.
In the first subform you set default value for transactionType control as a ="active", in the second subform: ="passive".
Now you can set visible parameter of transactionType controls in both subforms to no. In form view you won't see them, but if you create new record, the will add proper information to your table.
Are your subforms based on query? If no, go to subforms data source, create query based on your table and in the criteria of transactionType field set respectively "active" (in the firs subform) and "passive" (in the second one).
When you reopen
your form, thanks to query filter you have set in step 5, subforms will
display only actives or only passives. If you chose that solution, this will work for new data only. If you already have some data in your table, you should manually complete trasactionType for each existing record.

Related

Form to edit table selected from combobox

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.

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.

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.

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.