Autoupdate Function

rabuayya

Registered User.
Local time
Today, 06:50
Joined
Aug 29, 2012
Messages
26
Hi folks,
I have this dilemma which could be a breeze to some of you experts out there. I am just beggining to use Access. I took an online course which taught me basics only.

Iam trying to design a database for human resources to track absense of employees. I have creates the following 2 tables

Table1 with title EmployeesList and fields EmpID, EmpName, EmpDOB, EmpGen

Table2 with title Absense and fields Absense#, EmpId, EmpName, AbsenseDate, ReasonForAbs

I then made a one to many relationship between (EmpID) in the EmployeeList table and the EmpID in the Absense table.

I also created an Absense form.

I am trying to accomplish the following:

When the user enters the EmpID in the Absense form I want the EmpName in the form to automatically update to the name of the employee matching the EmpID entered. This way the user inputing the data makes sure that they are recording the absense for the right employee and that they did not miss enter the EmpID of another employee.

From reading on the net for a while now, I could kind of understand that I need to use an AfterUpdateEven function, but I still don't really know how.

Any help would be greatly appreciated.
Thanks
Rami
 
I would use a main form with sub form that is linked to the main form form using EmpID in each table. I would change one or two fields. The attached db is a simple example.
 

Attachments

Thanks a bunch.
Although this wasnt what I asked for but it's much better than what I had hoped to accomplish. Thanks for the example. Was a big help
Rami
 
Okay I tried to copy your example as much as I could but it seems that I didnt do it perfectly. I have one slight problem. which is that whenever I selected the employee name and entered the absence data and saved the form, The EmpID field remains empty in the Absence table.

Do I have to somehow link the EmpID field to the selection in the combobox in the form? If so how ?

Thanks Again!
Rami
 
You need to set the "Link Master Fields" property and the "Link Child Fields" property of the sub form control. These are NOT properties of the actual sub form. They are properties of the control on the main form which holds the sub form.
Open the main form in design view. Open the "Properties". Click ONCE on the sub form.
Set the "Link Master Fields" property to: The name of the control on the main form that holds the data that links the two forms. In the example I gave that was "Combo0", which held the "EmpID"
Set the "Link Child Fields" property to: The name of the control on the sub form that holds the data that links the two forms. In the example I gave that was "EmpID".
Post back if you need more help.
 
That worked fantastically! :)
Thank you very much
Rami
 

Users who are viewing this thread

Back
Top Bottom