form & subform auto update related field

  • Thread starter Thread starter Maggie
  • Start date Start date
M

Maggie

I have a main form & a sub form linked by a primary key
(HRID). When I enter the main form and select an HRID the
subform comes up with only the related records. When I
add NEW records to the subform I want it to automatically
add the HRID given in the main form so that the records
stay linked. Right now when I enter new records in the
sub form it leaves the HRID blank.

Do I add an event procedure to the Before Update or After
Update?

How do I write the code?

Any help would be greatly appreciated by this amateur.

Thanks,

Maggie
 
Maggie said:
-----Original Message-----
I have a main form & a sub form linked by a primary key
(HRID). When I enter the main form and select an HRID the
subform comes up with only the related records. When I
add NEW records to the subform I want it to automatically
add the HRID given in the main form so that the records
stay linked. Right now when I enter new records in the
sub form it leaves the HRID blank.

Do I add an event procedure to the Before Update or After
Update?

How do I write the code?

Any help would be greatly appreciated by this amateur.

Thanks,

Maggie
.

Maggie,

What I do is for the default value of the HIRD text box
on the subform put in the following...

=[forms]![your main form here]![HIRD]

Of course you don't need to display it so you can hide
it or put it on a header or footer and hide the header or
footer.

hth

Ivan
alovercast @ yahoo
 
It worked!! Thanks!

M
-----Original Message-----
Maggie said:
-----Original Message-----
I have a main form & a sub form linked by a primary key
(HRID). When I enter the main form and select an HRID the
subform comes up with only the related records. When I
add NEW records to the subform I want it to automatically
add the HRID given in the main form so that the records
stay linked. Right now when I enter new records in the
sub form it leaves the HRID blank.

Do I add an event procedure to the Before Update or After
Update?

How do I write the code?

Any help would be greatly appreciated by this amateur.

Thanks,

Maggie
.

Maggie,

What I do is for the default value of the HIRD text box
on the subform put in the following...

=[forms]![your main form here]![HIRD]

Of course you don't need to display it so you can hide
it or put it on a header or footer and hide the header or
footer.

hth

Ivan
alovercast @ yahoo
.
 
Back
Top