MS Access - populate checkbox list from table - ms-access

I'm using a local Access database. Let's say I have 3 tables -
Projects, Contractors, Project_Contractors (linking table, multiple contractors can work on multiple projects).
I'm building a form to be used to create a new Project entry. I want this form to have a checkbox list of all the Contractors, so the form will add a new entry to the Projects table as well as populate the linking table.
I'm very experienced with SQL, but not with Access. Is there a way I can populate a list of form options directly from the Contractors to complete this? I'm using Access 2013.

A listbox control is pretty good at accomplishing this. With larger datasets it can be clunky to scroll through them all, and if you can't make it tall enough to show all rows you also lose visibility on previous selections, but it's pretty easy to set up and link to the Contractors table (you should be able to do it through the wizard, or type some SQL into the control source).
Turning on the multi-select property of the listbox should do what you are looking for. MultiSelect Property
Getting the selections out of the listbox to generate your append queries I think requires VBA. Here's a link explaining how to accomplish it. Clicky
EDIT: to more directly answer your question, you could use checkboxes by adding a boolean field (there's a checkbox option there) to your Contractors table and use the table as a subform in your entry form. I personally think that's bad design, and the steps to clean it up make it way more complicated than using a listbox.

Related

Access: How to structure input vs read only forms

Ive got a peoples DB and after some development my recordset for the main form is not updatable because of subqueries etc etc..
All this is because i redesigned the DB to resemble real life more, meaning i added some tables that could track certain things. This made the relations a little more complex and now im left with a DB i cant add new records to or edit hahaha and thats pretty useless
So I'm left thinking it can't only be me so there is either a simple solution i can't see or i have designed my forms totally wrong.
Whats the praxis in design/structure when you have/get a form based on a recordset that's not updatable in a "regular" peoples DB and you want to add or edit details in it? (think HR managment DB)
(Reason for the recordset being un-updatable: The recordset is based on a query that gets records from 3 related tables and does a MAX function on a date field to get the most recent record on two of the tables)
Now i have a mainform and three subforms on it. I can edit/add info in the subforms of course but the mainForm displaying names and other personal details is not updatable...
The mainForms Query is querying the tblPerson, tblInmate, tblClassificationHistory and tblSquadHistory...
In your case, I would recommend two possibilities:
Build an extra form for input and edit data for persons where the only record source is tblPerson. This input/edit-form you can open in your main form via button or ribbon for example. You can build one form for input and edit data and change the behaviour by VBA-Code (or even Macros?). Or you can build two forms for edit and input data seperately. Also you can add OK and cancel buttons to safe or undo your changes. The possibilities are endless. This is basis ACCESS knowledge and there are tons of tutorials out there, so I will not explain this further.
Change the query on the main form. If you have a continuous form and you do not want to add a new form, you should edit your query. I can not estimate your described query complexity with given information, but there must be a way to get the "MAX-date"-recordsset without aggregated ("Group By" -Statement) query results. Your goal is to change your main-form query, that it does not have any "Group by" part. Be aware that you can use subquerys to do the "Group by" for finding the "Max-Value". You should also check your main form query, if you really need all queried fields for the main form. Let your three subforms do the data query work.
Basically, the perfect user interface (UI) as forms in ACCESS depends on the users preferences, expectations and the use case itself. So you have to find out, which design suits best for your application. You can do some research on UI design patterns if you want get knowledge from recent experiences. It is a huge field of expertise!

Form - Create new record in *different* table based on current form data

I'm building a risk and issues tracker and have become stuck after some good initial progress. I'll explain my setup now.
Tables
A table containing all open projects
A table containing all open
risks and issues
Relationships
A one-to-many relationship between with project ID (Primary Key in the project table) to the risks and issues table
Queries
A query that will filter results from the projects table that have been selected in a combo box
Forms
One form containing a combobox that allows the user to select a project. There is also a text box, which will be populated based on the selected project. The text box is populated using DLookUp on the above query, and I have chosen a field to be populated from that. This all works fine.
I am able to select a project and see a little information about it using the above set up. The next step for me is to be able to add a risk or an issue.
What I would like to happen is to have a create Risk / Issue button, which will pull across the Project ID (primary key) from the selected project, and add a new record in the **risks and issues* table. I will also need to add in additional information about the risk, dates, owner etc.
Also, by having the project primary key tied to each risk, I should be able to pull in any additional info about the project that I require.
I can write more if required - I'm not really sure which information is needed. Also, the form 'sits on' my projects table which could well have been the wrong way of doing things, however I still don't know how to bring in the data from two different tables.
I appreciate any effort and patience put towards this.
From my understanding of the question it sounds like your trying to update your risks and issues table with a single form that is bound to your projects table. If you're adding a record to risk issue table with a bound form it needs to be bound to that table.
My best answer would be to start fresh with a new form created by the wizard.
Make sure you have all the fields you want in your form in the risks and issues table.
Create a form based on this table using the wizard.
Change the Project ID control to a combobox by right clicking and selecting change to, combobox.
Set the row source to take project id and project from the project table and then make sure project id is the bound field and project is the displayed field(by adjusting column widths and bound column properties).
After doing this you should have a form that updates your risk and issues table while selecting the project from your project table. If this is not what you were asking or you wanted to do it a different way let me know I'll see if I can help.

How to recreate Northwind OrderLineItems type of form

I've been creating a database and adding forms.
My current issue is making a user friendly form where there are multiple subrecords, like 1 order record showing many related orderDetail records.
The Northwind Database has a nice example of this.
OrderLineItems is a simple form that fits into OrderDetail.
I opened a second version of Access, and tried to create a form that mimics OrderLineItems. I can't do it. I noticed two things.
In Northwind, many forms have a blue dot on the icon. These can't be opened in Design View. Why? It makes it harder to see what is going on.
No matter what I do, I can't seem to get the selectable options to even remotely line up in terms of quantity between the OrderLineItem and my form. There are about 29 (under ALL) in Northwind and WAY too many to count on mine. I'm trying to figure out what the magic selection is to make them match, but can't find it.
What's the best way to make a form setup like Northwind's OrderDetail with OrderLineItems?
Thanks

Parent-Child Database (MS ACCESS)

I'm trying to build a database for a hospital program. I have two tables that are related in a parent-child relationship. I have a form to add new records (records that dont already have a parent record) and I want to build forms that allow me to view all of a parent record's "children" as well as allowing me to edit them. I want this form to allow me to search for a record in such a way that only one parent record can be
returned.
Please see my database at http://rapidshare.com/files/283207434/IC.mdb.html
-check the form called "TEST". I can't get it to work so that the main form controls can act as filters to display the child records in the subform. I have been to many many forums and my lack of knowledge makes forum tag almost useless. A friend told me that this service was fast! If there is someone out there willing to help this poor soul over IM or something, that would be terrific! But I'm willing to work with you here too :) Hope to hear from you soon!!!
-Thanks
Zorkmid
There isn't really any code involved. From what other forums have told me, I don't need any code. Here's what a MS MVP said. I've tried all that, and I cant pinpoint the errior.
Build you main form based on the main (parent) table. DO NOT use a sql join
to bring in child records. Simply build a form on this main table.
To have the form "jump" for move to selected name simply use the combo box
wizard and drop in a combo box (follow the instructions).
Now, create a continues form based on the child table. Again, you can build
this form and base it on the child table. Again, don't use a sql join, nor
try to bring in any fields or parts of the parent table.
It is assumed you also correctly setup the relationship between the two
tables in the relationship window.
Now, bring up your "main" form (the one based on the parent table) in design
mode. Make sure wizard are enabled, and then drop in a sub-form control and
follow the wizard instructions (choose the correct form based on the child
table). Ms-access will setup this for you.
The end result is that if you navigate in the main form, the child form (sub
form) will follow and display the correct child records. and, in place of
using the navigation, if you use the combo box created by the wizard, then
again when the parent form move to a record, the child form will display the
correct records.
All of the above can be done without you having to write one line of code.

checked list box

I am new to Access and i am in the process of creating a database for some of our users. I have designed a form where the user name, first and last name etc are inputted.
Some of these users work for more than one department which means I need some type of listbox control that allows them to select more than one department when they enter their contact info.
In VB Studios 2005, this control is called a CHECKED LISTBOX. I have looked everywhere in access but cant seem to find it or anything closely similar.
The option of a listbox or combobox is not feasible here as these only allow the user to select one option only when inputting their details. Any help with this is much appreciated.
Use an ordinary list box with the "Multi Select" property set to "Simple".
The user can then click multiple list items, all of which stay selected until they un-select them again.
You may wish to consider a subform, as this will save you the trouble of updating a table with the data from a list box. A subform can use a department-person junction table with person id as the linked child field and master field. A combobox bound to department id will allow the user to select departments.
If you are really set on having checkboxes, Stephen Lebans has a sample database that uses the built-in Access listbox with checkboxes (from one of the Access wizards).
There is another choice:
If you are using Access 2007, you can declare your field as a lookup field accepting multiple values.
When you bind the list box to that field, you will get checkboxes.
It's easy to use them.
You'll also find more information is available from the MS Office website.
However, note:
This is only possible in the new Access 2007 database format and you will not be able to save your database to the older MDB format.
Multiple value fields are not compatible with most other databases, meaning that if you decide one day to upsize to SQL Server, you'll have to redesign your tables to use a junction table as Remou mentioned.
These multi-value fields are difficult to use from VBA: the value they return is in fact another recordset that you must iterate through to get all the values.
Having said that, if you just want something simple and you're not planning on manipulating the database from code, then it can be a practical option, albeit not a very compatible or future-proof one.
I'm not using them, but I think others should be able make their own decision knowing what is available to them.