• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 334
  • Last Modified:

Referring to a product ID field in a subform - access 2010

I have created an order form which contains two subforms; one for displaying customer details and one for displaying product details. I have included a command button next to the product details subform that opens another product form which allows the user to search and find a product.. Once the user selects the required product , I have a macro that goes back to the order form and tries to paste the selected product id into the products subform. Can not get access to refer to the product id on the products subform.
0
Maria Gibbs
Asked:
Maria Gibbs
  • 8
  • 7
1 Solution
 
IrogSintaCommented:
To refer to it, use:
Forms!NameOfForm!NameOfSubFormControl.Form!ProductID
0
 
Maria GibbsAuthor Commented:
Still getting error msg as shown on the below screen dump when I select command button ‘select product’ which runs macro mcr_copy_selected_product. Pls see attached doc.
error.docx
0
 
IrogSintaCommented:
Can you post the code where you inserted this line?

Ron
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Maria GibbsAuthor Commented:
It is part of the mcr_copy_selected_product macro which is the last screen dump in the attached file.
0
 
IrogSintaCommented:
My bad. I didn't realize you were using macros.  I'm not sure how you would do it using that.  That seems like a lot more work though rather than just using something like this in code:
Forms!NameOfForm!NameOfSubFormControl.Form!ProductID = Me.ProductID

Open in new window

0
 
Maria GibbsAuthor Commented:
Thank you but this example will be given people who have no knowledge of VBA so i need to get to work with no coding
0
 
IrogSintaCommented:
Okay, you need to use the SetValue action to do this.  If SetValue does not show up on the "Add New Action" dropdown, just click on the "Show All Actions" on icon on the Ribbon.  Here's what the macro looks like:

setvalue
0
 
IrogSintaCommented:
And just in case you weren't aware, you can use the builder icon and use the builder to come up with the same syntax I presented earlier.
builder
0
 
Maria GibbsAuthor Commented:
I have replaced the copy/paste and gotocontrol actions in the macro with the setvalue. IT is now working, however when i try to use the gotocontrol action to pass control to the quantity field i encountered the same problem. I have attached a new file attachment showing the error msg and the macro design. Thank you for your help. Any more suggestions?//?
0
 
IrogSintaCommented:
I don't see a new attachment.
0
 
Maria GibbsAuthor Commented:
i am attaching it again
error1.docx
0
 
IrogSintaCommented:
I don't understand what you're trying to accomplish.  If you're trying to set the quantity, why don't you just do it the same way we did the Product_ID?
0
 
Maria GibbsAuthor Commented:
i am passing control to quantity so i can activate events on product ID and to actually get the gotocontrol action to work for future references.
0
 
IrogSintaCommented:
MariaGibbs,
I'm more familiar with vb coding so what I know in macros is from the help file and accordingly, if you use GoToControl you should only use the name of the control and not the full syntax.  Also, if you want to go the Quantity control in a subform, you need to GoToControl to the subform first, then GoToControl again to the Quantity.  

The better option is to use the SetValue action (even the help file mentions this).  You only need to do a call to SetValue once because it uses the full syntax of the control.   ( i.e. Forms!frm_order!etc... )

Ron
0
 
Maria GibbsAuthor Commented:
I will give it a go. Thank you for your help.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 8
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now