Copy fields in subform and paste in another one (1 Viewer)

falcondeer

Registered User.
Local time
Today, 02:39
Joined
May 12, 2013
Messages
101
Hi

I need to be able to copy fields from subform-1 and paste them in same fields in subform-2 when I update a comb box in subform-2 using VBA.

Please see the below picture

Thanks
 

Attachments

  • Picture 1.png
    Picture 1.png
    118.3 KB · Views: 97

MajP

You've got your good things, and you've got mine.
Local time
Today, 05:39
Joined
May 21, 2018
Messages
8,602
See same discussion here

IF your button is on the main form then your syntax is something like

Me.SubForm2Name.FORM.Size = Me.Subform1Name.FORM.Size
....
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 05:39
Joined
May 21, 2018
Messages
8,602
If you want the code to be called from Subform2 then
Me.Size = Me.PARENT.Subform1Name.FORM.Size
 

falcondeer

Registered User.
Local time
Today, 02:39
Joined
May 12, 2013
Messages
101
If you want the code to be called from Subform2 then
Me.Size = Me.PARENT.Subform1Name.FORM.Size
Error 2465 happened, this is my code:

Private Sub PROV_Status_AfterUpdate()

If Me.PROV_Status.Value = "Requisted Item given" Then
Me.PROV_Size = Me.Parent.tblPrescribedItems.Form.PR_Size
Else: End If

End Sub
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:39
Joined
May 7, 2009
Messages
19,246
Can you try:

Private Sub PROV_Status_AfterUpdate()

If Me.PROV_Status.Value = "Requisted Item given" Then
Me.PROV_Size = Me.Parent!tblPrescribedItems!PR_Size
Else: End If

End Sub
 

Gasman

Enthusiastic Amateur
Local time
Today, 10:39
Joined
Sep 21, 2011
Messages
14,442
Is that meant to be Requested Item given?
 

falcondeer

Registered User.
Local time
Today, 02:39
Joined
May 12, 2013
Messages
101
Can you try:

Private Sub PROV_Status_AfterUpdate()

If Me.PROV_Status.Value = "Requisted Item given" Then
Me.PROV_Size = Me.Parent!tblPrescribedItems!PR_Size
Else: End If

End Sub

Sorry to say it but I got the following error: MS Access can't find 'tblPrescribedItems' referred to in your expression

By the way all those fields are a combo box fields including PROV_Size and PR_Size
 

Gasman

Enthusiastic Amateur
Local time
Today, 10:39
Joined
Sep 21, 2011
Messages
14,442
I can't help thinking your structure is all wrong.?

What it you need Accessory4?

Normally you would just use an ID field that identfies that accessory, select it and any descriptive data comes in from it's table?, not copy descriptive data all over the place?
 

falcondeer

Registered User.
Local time
Today, 02:39
Joined
May 12, 2013
Messages
101
I can't help thinking your structure is all wrong.?

What it you need Accessory4?

Normally you would just use an ID field that identfies that accessory, select it and any descriptive data comes in from it's table?, not copy descriptive data all over the place?
Thank you, its only 3 accessories there is no 4th, and I just don't want the user to fill same fields again when the "Requested Items are given" but if "Different item is given" then the user have to fill different item with its different accessories.

So again I wanted to find a way to fill all the fields in subform2 (tblProvidedItems) when "Requested Items Given" is chosen instead of filling them manually again.

May be you are right and my db is not well designed from the beginning but this is the best I could do.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:39
Joined
May 7, 2009
Messages
19,246
Sorry to say it but I got the following error: MS Access can't find 'tblPrescribedItems' referred to in your expression
you need to investigate the Real Name of that subform by going on design view of your form, clicking on that subform and
looking at Property Sheet->Other->Name.

then substitute the Real name to the code i gave you.
 

falcondeer

Registered User.
Local time
Today, 02:39
Joined
May 12, 2013
Messages
101
you need to investigate the Real Name of that subform by going on design view of your form, clicking on that subform and
looking at Property Sheet->Other->Name.

then substitute the Real name to the code i gave you.
Thanks
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 10:39
Joined
Sep 12, 2006
Messages
15,707
I struggle to see why you would want to copy fields from a sub from to another. It just sounds like a data structure problem. Generally, which fields in subform1 would be relevant to subform2 - that would need a copy? I just can't see this.
 

Users who are viewing this thread

Top Bottom