MS Access. Names in forms instead of ID's - database

i have two tables
student(studentid, name, class)
Course (courseID, CourseName, CreditHours)
these tables have many to many relation ship so i created a third table
student_course(studentID,CourseID)
Now i have designed the forms in ms access through which user enters data in student and course tables
But i want to design a from through which user can assign courses to students which means user
have to enter data in student_course table.
but i want to design a form though which users can see and enter the student name and course name insted of ID's at backend ID should store in student_course table,
Can anyone help me in this matter.

You can use a combo box .. try to insert a combo box on the form using the wizard and it should walk you through the steps in showing the course name in the front end and saving the course id in the back end database ...

Related

How do I create a new record in a table according to primary key of another tab in an Access Form?

I have two tables. The first one is the list of my customers with their auto-generated ID, their name and their status in my DB. The second table is the list of my customers' phone numbers and whether it is a mobile or landline. One customer can have many phone numbers, that is why I keep in every record in table2 the CustomerID.
I want to create a form that allows me to add a new customer to my list, and in a separate form, add one or more phone numbers ACCORDING to the CustomerID I've just add. In the future I will have many more tables like Customer_Phones_List also linked to Customers_List so I'm not sure if a subform is the best option.
How do I do that in MS Access ?
Build form/subform(s) arrangement. Can use a tab control for multiple subforms to conserve screen space. Each page of tab control can have a subform that is linked to data on main form.

MS Access form to update multiple tables without subforms

I am quite new to creating dbs in Access but I am not a fan of subforms, I can already tell that much, they are nice for one to many relationships (one customer, many orders) but when I just want to reduce redundancy and create a one to one relationship between tables and I only at all times would need one record from another table, subforms no longer feel so nice.
My example:
I have 2 tables, 1 for companies (ID, company name, country ID) and one for countries (country ID, name of the country). To eliminate repetition of country names I use country ID to link the 2 tables, and only add the ID of the country, not its name.
When I create a form for the "companies" table I want one field that says where that company is located instead of a subform (because I still havent figured out how to hide the box around it), so practically having one field that's connected to a different table.
And then through the one to one connection, when a record is selected the form would show in one field where the company is located. Is this possible?
Extra: I have 2 countries in my "country" table, the UK and Germany, but a new company I am adding a record from this form, is located in France, is it possible that I just enter France into the field and it automatically creates a new record in the "country" table for France, and also adds the new record's ID to the "company" table, to the company that's located in France
It seems your form and subform are based directly on tables. Try basing your main form on a query:
SELECT
company.ID,
company.CompanyName,
company.CountryID,
country.CountryName
FROM
company
INNER JOIN country ON
company.CountryID = country.CountryID
This will eliminate the need for a subform.
Extra: You may actually want to have the 'country creation' function on a separate form, or invoked from a button push on this main form.
Having Country IDs to force users to pick a standard country from a list is a very good idea. However if you also let them arbitrarily enter new ones in the same box you're trying to prevent them from mistyping in, that good work can come undone.
Yes this is absolutely possible. The way I do this is with unbound forms, so I control all of the SQL statements to tell the data what to do and where to go.
Since you have 3 fields being sent into a row in the "companies" table and 2 fields being sent into a row in the countries table with 1 of the fields being in a relationship (I'm assuming 1 to many), create 4 textboxes (or whatever other control) on your form. The controls will be for: ID (assuming this is inputted by the user and not an autonumber. If it is, please comment below), company name, country ID, name of country. When you fill all of them out, have a button with a Click event. In here you will have 2 SQL statements to insert records, 1 for each table.
The code will look like this:
Private Sub button_Click()
DoCmd.RunSQL "INSERT INTO companies VALUES ([ID].Value, [company name].Value, [country ID].Value)"
' The words in the [] are the names of your controls on the form
DoCmd.RunSQL "INSERT INTO country VALUES ([country ID].value, [country name].value)"
End Sub

multiple records for one person in a form in Access

For my internship I am making a database in Microsoft Access about employee's accidents at work. There is one table and one query in the database. For the form I want it to have one employee and all the previous and future dates of all the accidents they have had and the comments to show if they are repeating them. If this is possible how can it happen?
You'll need at least two tables: one table for the employee information (their name, employee number, and stuff like that) and another table for the accidents (employee number of the person who had the accident, when it happened, what happened, etc.). Then you could use a Form with an imbedded subform to display the information.
Microsoft has provided detailed information on how to use a subform here:
Create a form that contains a subform

How can I make a form input for multiple tables in Microsoft Access 2010?

I want to make a form in Access 2010 that would allow me to enter the information about an invoice, and be able to choose the name of a customer, a store, and an employee to associate that invoice with. The customers, stores, and employees are stored in separate tables with mapping tables (i.e. invoice-customer, which just has InvoiceID and CustID) connecting them to invoice.
When I make a form that only makes records for a single table's information, I can use the form to make new records and edit previous records fine, but when I any form I make that has information from other tables, it will only display current records, not make new records or edit them. How can I make a form that works that way?
You may wish to read Fundamentals of Relational Database Design, Paul Litwin, 2003, I suspect you do not need the junction tables for customer, store and employee - junction tables are generally only needed when you can have several of something associated with one of something else, for example, several locations for one invoice.
This would make things a lot easier for you, because you could use comboboxes to allow the user to select these items by name, which would then write the id back to the invoice table.
You might like to look at the Northwind database (nwind.mdb) for some ideas. It ships with all versions of Access.

Troubleshooting a many-to-many relationship in Microsoft Access?

I created a database that holds a STUDENT table, a COURSE table, and an intersection table named STUDENT_COURSE. However, I have problems with duplicated rows and I don't know how to solve them.
Here are pictures of the tables in design view and many-to-many relationship I have created.
http://imgur.com/P7DI1l&THH7A (Be sure to click the "Second Image" link to view the relationships picture.)
In an attempt to simplify data entry, I used the form wizard to set up a SCHEDULE form (and subform).
http://imgur.com/isf4Y&ARYu3
As you can see, one enters the student data in the form and the course data associated with that specific student in the subform. However, when one enters course subform data, it creates a new courseID (autoNumber). This new courseID results in duplicate courseNames (See "Linear Algebra" entries in above imgur link via "Second Image") so that associated students aren't grouped together when one queries by class.
Is there a flaw in my design? Am I not using the form correctly to enter data? Please help me troubleshoot this.
Thank you very much!
Your subform should be based on STUDENT_COURSE table and not on COURSE one. You can still add columns from COURSE table to the subform to display course related data.
Here are some links:
http://www.techrepublic.com/article/accommodating-a-many-to-many-relationship-in-access/5285168
http://www.dhdurso.org/articles/ms-access-forms-pg4.html
http://en.allexperts.com/q/Using-MS-Access-1440/Help-form.htm

Resources