Link to home
Start Free TrialLog in
Avatar of Maria Gibbs
Maria Gibbs

asked on

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.
Avatar of IrogSinta
IrogSinta
Flag of United States of America image

To refer to it, use:
Forms!NameOfForm!NameOfSubFormControl.Form!ProductID
Avatar of Maria Gibbs
Maria Gibbs

ASKER

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
Can you post the code where you inserted this line?

Ron
It is part of the mcr_copy_selected_product macro which is the last screen dump in the attached file.
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

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
ASKER CERTIFIED SOLUTION
Avatar of IrogSinta
IrogSinta
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
User generated image
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?//?
I don't see a new attachment.
i am attaching it again
error1.docx
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?
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.
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
I will give it a go. Thank you for your help.