How to filter a table field's listbox by the current record - ms-access

How do I set up a table's field so that the listbox is filtered by that row's data?
I have a master table (TblMain) with 2 important fields: Client and Division. Currently, the Division field is set up as a simple Listbox that pulls from another table (TblDiv).
However, the Divisions are specific to each client with little overlap. My current basic setup doesn't make that distinction, so any division can be chosen for any client.
How do I set up Division so that the listbox is specific to that row?
I've tried doing an inner join within the row source (i.e. Select TblDiv.Div from TblMain Inner Join TblDiv on TblMain.Client=TblDiv.Client) but that doesn't seem to work, probably because I'm not referencing the Client value of the active row.
(I should add I'm not talking about Forms or Reports. Just the Table object)

Are you trying to add a look-up field to a table? This is almost never a good idea. Are you trying to filter a combobox on a continuous form? You cannot sensibly do this - any change will affect the appearance of every row, which is confusing to the user. There are work-arounds. For example, you can show a textbox for the Reference and a "Change reference" combo. This will avoid confusing users because the bound textbox will not update. You can set various properties of the change combo with conditional formatting to make it all prettier. Alternatively, you can use two subforms or a pop-up form to edit data.

Related

Ms Access Datasheet view - only one column editable

There is access datasheet sub-form and users should only be able to edit count column. How can that be done ?
Currently, If I change the form property Allow Edits = True, users can update any cell.
Also, the user should be able to enter different count values. If a user types 1 in first cell, it get copied for all the rows.
How can this be achieved?
For each control on the form that you don't want editable, set the Enabled property to False (or the Locked property).
For the count copying to all rows, we need to see the query that this datasheet is based on to answer that. If the count is an unbound textbox, you will get the behavior you are seeing as Access will only create a single instance of the control, then repaint that single instance across all rows (note that this is the same with continuous forms as well)
Instead, create a query that has this field (or a dummy table) and bind to that, making sure to bind the textbox to the dummy field, and then you should be able to edit the value on a per-row basis.

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).

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.

Access: Multi-value field

I am trying to design a form where the user can search records to filter a report. The user must be able to select many values from a particular field (multivalued field). I understand I can use a list box, but the field has a total of 3,000 records and cycling through is too much. I just want to know what other ways I can let the user insert multiple values?
I have these ideas, but maybe you guys have another better way:
Creating multiple combo boxes and keep them hidden until the user hits an “add” button, but this limits me to the amount of values I can have. If I have 10 hidden combo boxes I can only enter a total of 11 (10 hidden plus the original visible) values.
Is it possible to have a temporary data grid where the user just enters the values.
Then comes the problem of getting this into the SQL Record Source. I am thinking of the SQL IN clause.
Any help or ideas, will be greatly appreciated.
I think that you should create Comboboxes where values from next combo are dynamically populated when value in previous Combo has been changed so that way you can create hierarchy of values to select.
I've done something similar for a few different applications in slightly different ways. Basically, I present the user with a table, allow them to right-click > filter (the same could be accomplished by providing a filter textbox for each corresponding field in the table you want to allow filtering on... in your case it sounds like you only need one). The filter box allows them to use 'and' and 'or' along with the actual text of what they're looking for. Then they click a button that opens the report and fills the report's filter field with whatever filter they had applied.
Of course, this assumes the user is familiar with the data they're filtering, and requires a bit of training, but for me it was a simpler alternative than displaying a list with a bajillion entries in it. Your mileage of course may vary :)

Access: Select multiple records to print report

I am trying to design a form where I can select multiple records and on button click open the report with the selected records IDs.
I am thinking maybe make a continuous form with an added unbound check box control where the user selects the appropriate records they want to display in the report. I am unsure how to later read this into a do.cmd OpenReport criteria property.
If there is an easier way to this please let me know.
Take a look at http://support.microsoft.com/kb/135546 or http://allenbrowne.com/ser-50.html. Another approach you could take is create a temporary table that contains a single field for your record ID. Using the code from the links, fill the temporary table with the record IDs that have been selected. Then all you need to do is change the query that drives your report to do an inner join with the temporary table.
Can you add a column to your dataset where they can determine which rows to print? You could add a printMe Y/N column, for example, and then use that field value to limit the rows for the report.