Problem with subform data based on form variables

mrod

New member
Local time
Today, 21:59
Joined
Jan 22, 2002
Messages
6
Let me preface this by saying I posted this message to the forms list and didn't get a useful reply. I am reposting to this list to see if what I am trying to do is better accomplished by using underlying VB code. Please comment on the design methodology that would usually be used to perform this type of task.

Thanks Much
-Matt

I am putting together a basic time tracking system and am having trouble with syncing the form and sub form when editing the timesheets.
I have a table called Time_Card which contains:

Time_Card_Key (Primary Key)
Employee_Id
Date_Worked

I have another table named Time_Card_Detail which contains:

Time_Card_Detail_key (Primary Key)
Time_Card_key
Work_code
Etc..

The database is constructed so that Time_Card.Time_Card_Key has a one-to-many relationship with Time_Card_Detail.Time_Card_Key.

The recordsource for the form is Time_Card. The basis of the form is to select an Employee_key(select query form another table named Employee_Name) and Date_worked(Based off of a query which using the given employee key to limit the Time_Card_key value to one record). Which are both values in the form. Once this is done the corresponding detailed entries should show up in the subform.

My Master-Child links are Time_Card.Time_Card_key
Time_Card_Detail.Time_Card_Key

So my question is how do I pass the Time_Card_Key value I derive in the query underlying Date_Worked to the form which in turn should syncronize the subform? Am I doing this completely wrong or am I missing somthing simple? I have tried to base the form off of a query which determines a value of Time_Card_key based on the employee_key and Date_worked selected, however since there is no initial value when the form opens, the subform is not even visible.
 
What you need to do is to link the main form with the sub form via the Child Field / Master Field property that is available when you click on the subform and look in the Properties list.

You will want to have the both of them read:
Time_Card_Key

Then, what you need is to determine when to run the code: Me.Requery

It would be when you select your record from your main form so that the subform will change.

BL
hth
 

Users who are viewing this thread

Back
Top Bottom