Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically fill fields in "many" table for one-to-many relationship

Status
Not open for further replies.

MistyWolf

Programmer
Jan 27, 2006
7
0
0
US
I have an Employee data entry program that tracks multiple employees as they perform different tasks throughout the day. I want to be able to have a log of their attendance status throughout the day. The status being "LOGIN", "LUNCH", "LEAVE", "LOGOUT". I can set this up through a form/subform relation to manually set these values, but I want it to happen programatically.

The employee table fields:
pkEmployeeID/Primary Key
empCODE/Text
empNAME/Text
emptitle/Text
empDept/Text
empPassword/Text
fkSecurityID/Long
EmpLockedOut/Yes/No

The status table fields:
pkStatusID
Status
fkEmployeeID

What is the best way to do this? And how do I programatically add the status information based on the primary key of the employee table?

Thanks,

Scott
 
If you have established a relationship between the tables, using referential integrity, you MUST have a record in the Primary Table first. Then, when creating records in the child Table, make sure you populate the foreign key (with an existing Primary Key).
After that, the worlds your oyster...
 
Is your goal to add records for the other three status states in one steps, after say "LOGIN" is selected? If so you could use the [tt]After_Update[/tt] event on the [tt]subform[/tt] to create the records.
Code:
If Me.Status = "LOGIN" Then
  Me.Recordset.AddNew
  Me.pkStatusID = ?
  Me.Status = "LUNCH"
  Me.fkEmployeeID = pkEmployeeID
  Me.Recordset.AddNew
  Me.pkStatusID = ?
  Me.Status = "LEAVE"
  Me.fkEmployeeID = pkEmployeeID
  Me.Recordset.AddNew
  Me.pkStatusID = ?
  Me.Status = "LOGOUT"
  Me.fkEmployeeID = pkEmployeeID
End If

Funny thing about being unemployed, weekends don't mean quite so much, just means you get to hang out with your working friends. Primus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top