Loading subform with data from main form

S

SAC

I thought this would do it:

I put this in the before insert of the subform:

Me!txtJobID = [Forms]![frmInvoice]![txtJobID]

frmInvoice is the main form.

What can I do differently to make this work?

Thanks.
 
M

Marshall Barton

SAC said:
I thought this would do it:

I put this in the before insert of the subform:

Me!txtJobID = [Forms]![frmInvoice]![txtJobID]

frmInvoice is the main form.

What can I do differently to make this work?


You could use that code in the BeforeUpdate event, but this
whole exercise would be automatic if you set the subform
control's Link Master/Child Fields properties to the JobID
field.
 
S

SAC

Thanks!

I have an Invoice number as the parent field. Is there a way to use both
the Invoice number and the JobID in the Linked Field?


Marshall Barton said:
SAC said:
I thought this would do it:

I put this in the before insert of the subform:

Me!txtJobID = [Forms]![frmInvoice]![txtJobID]

frmInvoice is the main form.

What can I do differently to make this work?


You could use that code in the BeforeUpdate event, but this
whole exercise would be automatic if you set the subform
control's Link Master/Child Fields properties to the JobID
field.
 
M

Marshall Barton

Check VBA Help om the LimkMasterFields property for details.

In your case, you could set both of them to something like:
InvoiceNum,JobID
or whatever you real field names are.
--
Marsh
MVP [MS Access]

I have an Invoice number as the parent field. Is there a way to use both
the Invoice number and the JobID in the Linked Field?


SAC said:
I thought this would do it:

I put this in the before insert of the subform:

Me!txtJobID = [Forms]![frmInvoice]![txtJobID]

frmInvoice is the main form.

What can I do differently to make this work?


You could use that code in the BeforeUpdate event, but this
whole exercise would be automatic if you set the subform
control's Link Master/Child Fields properties to the JobID
field.
 
S

SAC

After I put that into the AfterUpdate event, the cursor won't go to the next
record on a the ds form. It stops on this control as it's the last one on
the form.

What do I need to do?

Thanks!

Marshall Barton said:
SAC said:
I thought this would do it:

I put this in the before insert of the subform:

Me!txtJobID = [Forms]![frmInvoice]![txtJobID]

frmInvoice is the main form.

What can I do differently to make this work?


You could use that code in the BeforeUpdate event, but this
whole exercise would be automatic if you set the subform
control's Link Master/Child Fields properties to the JobID
field.
 
S

SAC

Thanks! Didn't know I could use multiple fields.

Marshall Barton said:
Check VBA Help om the LimkMasterFields property for details.

In your case, you could set both of them to something like:
InvoiceNum,JobID
or whatever you real field names are.
--
Marsh
MVP [MS Access]

I have an Invoice number as the parent field. Is there a way to use both
the Invoice number and the JobID in the Linked Field?


SAC wrote:

I thought this would do it:

I put this in the before insert of the subform:

Me!txtJobID = [Forms]![frmInvoice]![txtJobID]

frmInvoice is the main form.

What can I do differently to make this work?


You could use that code in the BeforeUpdate event, but this
whole exercise would be automatic if you set the subform
control's Link Master/Child Fields properties to the JobID
field.
 
S

SAC

Works great after I put in the multiple fields in the link.

Thanks!!

SAC said:
After I put that into the AfterUpdate event, the cursor won't go to the
next record on a the ds form. It stops on this control as it's the last
one on the form.

What do I need to do?

Thanks!

Marshall Barton said:
SAC said:
I thought this would do it:

I put this in the before insert of the subform:

Me!txtJobID = [Forms]![frmInvoice]![txtJobID]

frmInvoice is the main form.

What can I do differently to make this work?


You could use that code in the BeforeUpdate event, but this
whole exercise would be automatic if you set the subform
control's Link Master/Child Fields properties to the JobID
field.
 

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