More Form/Subform problems

T

TP

Tina was kind enough to give me advice on how to create a form/sub form for
data entry, but I cannot get it to work. Previous post included below.

As Tina suggested, I have created a main form based on an Employee
Information table, and included fields containing the Employee Number, Last
Name, and First Name. I then created a subform based on an Employee Work
Tracking table with the fields containing the Employee Number (Link Child
Fields and Master Fields both on Employee Number). [Employee
Information].[Employee Number] & [Employee Work Tracking].[Employee Number]
also have a relationship in the Relationships window.

The subform contains fields to enter the type of work that employee did that
day, as well as the Start & Stop times. I want to enter the Employee
Number on the main form, tab to the subform & have the Employee Number
carried down to the subform so that I don't have to re-enter it repeatedly
as I enter data for that employee.

When I tried Tina suggestion, I cannot move to the subform because it is
telling me that I have left fields that are required in the Main Form's
source table null. I am not trying to _add_ information to the Employee
Information table, only to the Work Tracking table.

What am I doing wrong? If anyone knows of a web page with a tutorial on
this issue, I'd appreciate that as well. I didn't find Help to be of any
use for troubleshooting this. It does say: " When you use a form with a
subform to enter new records, Microsoft Access saves the current record in
the main form when you enter data in the subform. This ensures that the
records in the "many" table will have a record in the "one" table to relate
to. It also automatically saves each record as you add it to the subform."
.... but I think what I am trying to do must be possible.

Thanks in advance,

Patti

-----------------------------------------------------
Thanks Tina,

I'll try it & post back if I have any problems.

Patti
-----------------------------------------------------

you have a parent/child relationship between tblEmployees and tblEmplWork
(my names for the tables you described). the form/subform should mirror
this: main form bound to tblEmployees and the subform bound to tblEmplWork.
[suggest you set the tables' relationship in the Relationships window (see
the database window toolbar), on field EmplNum; and enforce referential
integrity.]
create a form bound to tblEmployees, as frmEmployees. create a form bound to
tblEmplWork, as frmEmplWork.
in frmEmployees design view, add a subform control, which i'll call Child1.
in the Properties box, set the SourceObject as frmEmplWork. set both
LinkChildFields and LinkMasterFields to EmplNum. now the subform records are
linked to and synchronized with the main form form records. each time you
enter a new record on the subform, Access will automatically enter the
EmplNum from the current record on the main form.
if you want to enter a date once, on the main form, and have it carry over
to field WDate on the subform, you can. add an unbound text box to the main
form (which i'll call MyDate), where you will enter the date. in the
subform's *form* event BeforeUpdate, or event BeforeInsert, add an event
procedure, as

Private Sub Form_BeforeUpdate(Cancel As Integer)

Me!WDate = Me.Parent.MyDate

End Sub

hth
-----------------------------------------------------
 
J

Joe Black

TP said:
Tina was kind enough to give me advice on how to create a form/sub form for
data entry, but I cannot get it to work. Previous post included below.

As Tina suggested, I have created a main form based on an Employee
Information table, and included fields containing the Employee Number, Last
Name, and First Name. I then created a subform based on an Employee Work
Tracking table with the fields containing the Employee Number (Link Child
Fields and Master Fields both on Employee Number). [Employee
Information].[Employee Number] & [Employee Work Tracking].[Employee Number]
also have a relationship in the Relationships window.

The subform contains fields to enter the type of work that employee did that
day, as well as the Start & Stop times. I want to enter the Employee
Number on the main form, tab to the subform & have the Employee Number
carried down to the subform so that I don't have to re-enter it repeatedly
as I enter data for that employee.

When I tried Tina suggestion, I cannot move to the subform because it is
telling me that I have left fields that are required in the Main Form's
source table null. I am not trying to _add_ information to the Employee
Information table, only to the Work Tracking table.

snip

If you are not trying to _add_ information to the Employee Information
table, only to the Work Tracking table then I assume that you have already
added the Employee Information previously and what you are trying to do is
add to the Work Tracking table for that previously entered Employee.

If that is right then what you need to do is move to that employee's record
first and then enter the Work Tracking data for that employee. You can move
to the employee record by clicking in the Employee Number text box and using
the Find command or you can create a combo box or list box that you can use
to select the Employee Number and automatically move to that Employee. To do
this, add a combo or list box to the form using the Control Wizard and
choose "Find a record on my form based on the value I selected in my combo
box".

Regards - Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top