I have a student database contains the following tables:
Student Table (Id, StudentName, ClassNum, ....)
Action Table (Id, ActionDate, studentID, Status, reason, note)
Status fields possible values are: attended(=1) absent(=2), permitted(=3).
I want to build a form has the two unbound fields (Class Number and date) in the top of the form. A subform should contain a grid (list) of all the students of that class number; each row of that grid consists of: Student name (non editable), status (drop-down list for example), reason (text box).
The form should show all the class students.
When the user enters data (status, reason and notes) the form should create a record in the action table with the student id, the date (entered in the top section) and the add data (i.e. status, reason made notes).
How can i build a form contains records from a table (with records not exist before adding them).
You need an INSERT SELECT action SQL to create a batch of records in Action table.
CurrentDb.Execute "INSERT INTO Action(StudentID, ActionDate) SELECT ID, " & _
"#" & Me.tbxDate & "# FROM Students WHERE ClassNum = " & Me.tbxClassNum
If ClassNumber is a text field, will need apostrophe delimiters for filter criteria.
This assumes each student can have only one class. If they can have multiple classes, then need ClassNumber field in Action.
Then filter form for that batch of records to do data entry to other fields in Action.
Related
I am trying to create a View using certain fields from a single MYSQL table. But in one of the fields in the Table, I need to populate the field from either one field in the table or another field in the same table based on the value of a third field in the table. Is this possible, and if so, how?
To explain, The table contains data from two suppliers. The entries in the table from "Supplier A" store the Account Number in field CustomerNumber while the entries in the table from "Supplier B" store the Account Number in field CustomerAcct. The view I need to generate needs to list all of the customer orders from both suppliers combined, and populate a single field in the view called AccountNumber with either the value from CustoomerNumber or CustomerAcct, depending on which supplier filled the order.
Is this possible?
You'd use the "case" function, as in mysql case
CASE
WHEN Supplier = 'A' THEN customernumber
ELSE customeraccount
END as accountnumber
I am developing an MS-Access application. The database contains an Activity table that has two fields to identify the location where the Activity occurred: StateID and CityID. Both fields are foreign keys to other tables (State and City). The City table has a foreign key to the State table, pointing to the State that contains that City.
I have an Activity form based on the Activity table. The form contains two combo boxes, one for StateID and one for CityID. I would like the user to select either the State or a City where the Activity occurred. If user just selects a State without specifying a city, no problem. However, if the user selects a City, I would like to update the StateID field with the State where that City is located. That would require an query on the City table to find it's related State.
How can I update the StateID field on the Activity table when the CityID combo box is updated? At the same time I would like to refresh the form so that that State appears in the State combo box.
Can anyone help me?
The solution was to add the following statement to the After Update event on the cboCity field:
Me!cboState = Dlookup("ParentStateID","City","ID = " & Me!cboCity.Column(0))
So I have an Access database that I'm trying to build and was wondering was there a way that if I type in an ID into one table that it can populate values in the adjacent column from another table.
For example I have table_1 that has columns User ID and User Number.
And now that I'm creating table_2 I want when I enter the User Number that it populates the value for another column which will be User ID, sort of how a vlookup would work in excel.
I already built a relationship for the User Number column in table_2 so when I type in the value its pulling from table_1. But I can't get column User ID to populate with the corresponding value. Thanks
You don't need to build a second table that duplicates the data. Since you already have it in table 1 you can always refer to that relationship when querying data and should do so in order to avoid discrepancies between the two tables. In this instance if you want to return the user id from table 1 when you specify a user number you should just create a new query using the sql code:
SELECT table_1.[User Number], table_1.[User ID]
FROM table_1
WHERE table_1.[User Number] IN (12345, 12346, 12347);
In this example, the 12345, 12346, 12347 represent your user numbers for which ID's you were wanting to return; so you should only replace those values with your search parameters.
I made linked forms to input data into a table called t_Transactions. These forms contain data from 3 tables. Those tables are:
t_Group: consists of group number (primary key) and group name
t_Member: consists of group number (foreign key), member number (primary key) and member name
t_Transactions: consists of transaction number (primary key), group number (foreign key), member number (foreign key), debit transaction, and credit transaction.
The first form (let's call it form A) contains data from the t_Group table. A second form (let's call it form B) is linked to Form A, and it contains data from the t_Member table, and a subform containing data from t_transaction. The subform only has 3 fields: transaction number, debit transaction, and credit transaction. (See picture 1 Picture 1 and Picture 2 for form pictures)
Now when I input the "transaction number", "debit transaction" and "credit transaction" fields in the t_transaction subform in Form B, all of the fields in the t_transaction table are automatically filled, but the group number field is left blank, like this. I want the group number field to be filled with data corresponding to Form A. How can I do this? I checked all my relationships, and it is correct.
Any help will be greatly appreciated.
I am building a training database.The tables I am using are: Employees, Training Courses, In Training, and Completed Training. I have a query that filters off of a form to show employees that have not received the training.
I want to add a checkbox next to the results so I can select some or all of them to be added to the In Training table. I have been stuck on this for days searching the internet and reading books looking for the answer.
Just saw this question. Here is an alternative solution to this problem. There is no checkbox, but you get a subform with combo box to update the course and progress for a particular employee.
Create 4 tables with the fields:
tblEmployees
EmployeeID (Primary Key)
EmployeeName (and any additional fields you might need)
tblProgress -> this stores "IN TRAINING", "COMPLETED" as 2 separate records
ID (AutoNumber) (Primary Key)
ProgressDesc
tblTrainingCourses
CourseID (Primary Key)
CourseName
tblEmployeeTraining -> here we are using composite key
EmployeeID (Primary Key)
CourseID (Primary Key)
Progress
Create a one-to-many relationship between tblEmployees and tblEmployeeTraining, linking the EmployeeID.
Configure the following fields in tblEmployeeTraining (in Design View), by selecting the [Lookup Wizard...] from Data Type column.
CourseID
Choose the tblTrainingCourses as the table for the Lookup Values
Progress
Choose the tblProgressas as the table for the Lookup Values
Create a Form based on the tblEmployees. You should get a subform included that will display the Course Name and Progress. Basically, the 2 columns in the subform will show combo box for you to select the course and the progress.
If you do not want the relationship in step 2, maybe you want to store the employee data after it is deleted, then you need to create a query and use it as the RecordSource for the subform. Instead of deleting the record from tblEmployees, you may want to add a field in tblEmployees to determine if the employee is active or not. Then, you can use the above steps and just do filtering on the form to display those active employees.