I am trying to copy the math result off of a subform to the parent form. I can't seem to just copy it. Maybe you could point me in the right direction. I am on Expert level 14 lesson 3 with my courses. If this is covered in future lessons could you tell me which one?
Kevin Robertson 3 months ago
What have you tried to copy the value?
Richard Van Wagoner 3 months ago
Richard Van Wagoner 3 months ago
I tried Forms![ProductTotal]! procedure. I have tried Dlookup.
Kevin Robertson 3 months ago
In the Control Source of the field on the Parent form use this syntax:
=[SubformName]![FieldName]
Example: =[OrderDetailF]![SumExtPrice]
Richard Van Wagoner 3 months ago
That is just what I wanted! Thank you!
Kevin Robertson 3 months ago
You're welcome.
Richard Van Wagoner 3 months ago
Just one more question on this subject. I am generating a report on this form. I can't seem to move that field to my report and make it work. Any suggestions? By the way, I'll tip you as soon as I am set up on Paypal.
Richard Van Wagoner 3 months ago
I was checking it is not putting the value in the table.
Kevin Robertson 3 months ago
Sorry. I didn't realise you were storing the value.
You could do something like this in the On Current Event of the parent form:
If Not IsNull(OrderID) Then
OrderTotal = OrderDetailF.Form!SumExtPrice
Me.Refresh
End If
I must not have things right.Is this supposed to be on the Parent form event ON Current Tab?
Richard Van Wagoner 3 months ago
Parent Form is Named ProductF. Subform is ProductDetailF. And the total in subform is SupplySum.
Kevin Robertson 3 months ago
The code needs to go in the OnCurrent EVENT of the Parent form.
Open the Property Sheet for the Form and go to the Event tab.
Click on the Builder button (see screenshot).
Kevin Robertson 3 months ago
Richard Van Wagoner 3 months ago
I am sorry to keep bothering you. But that is where I put it. Do I have my forms named right in the event?
Richard Van Wagoner 3 months ago
Richard Van Wagoner 3 months ago
Richard Van Wagoner 3 months ago
This is the error message I get when opening the product form.
Kevin Robertson 3 months ago
Remove the code from there and click on the builder button (...) at the right. If you get the Choose Builder dialog, choose 'Code Builder' to open the Visual Basic Code Editor. This is where you need to enter the code.
I haven't got that far into the lessons. Is the builder button on Parent form properties?
Kevin Robertson 3 months ago
Yes. See the screenshot I posted above. With the red square.
Richard Van Wagoner 3 months ago
Richard Van Wagoner 3 months ago
Richard Van Wagoner 3 months ago
This is the error message I get now when opening the parent Form. I have also included a screen shot of where I put the code.
Kevin Robertson 3 months ago
That's the Expression Builder. You need the Code Builder.
Kevin Robertson 3 months ago
Kevin Robertson 3 months ago
Richard Van Wagoner 3 months ago
I am not getting the chance to Choose the Builder That option is not displaying for me. I am clicking on the 3 dot on the right but all that comes up is the expression builder.
Richard Van Wagoner 3 months ago
Richard Van Wagoner 3 months ago
Is this the right place?
Kevin Robertson 3 months ago
Did you remove all the code you entered previously?
Kevin Robertson 3 months ago
Yes. Now enter the code between the Private Sub and End Sub.
Richard Van Wagoner 3 months ago
Yes, I removed it. Now I will put it in the right place. I have bothered you enough tonight, whether this works or not I will leave it as is till another day. Thank you so much!
Scott Axton 3 months ago
Richard -
In the picture I'm looking at it appears that you are trying to put your code directly into the property sheet instead of the code module associated with the form you are working with.
That is the reason you are getting the error.
So...
Try this:
1. Copy that code in the zoom box and paste it into Note Pad to save it temporarily. Close the Zoom Box.
2. Now click in the blank "cell" to the right of On Load. Press the Up Arrow on your keyboard once. It should highlight the contents in the on On Current line. Press the Delete key.
3. Now that we are sure that everything is out of the On Current, you should be able to click the ... button and it should bring up the Choose Builder dialog box. Click Code Builder then click OK.
Follow Kevin's instructions from there using the code you pasted in the Note Pad.
Richard Van Wagoner 3 months ago
I tried what you said and still an error. see images.
Richard Van Wagoner 3 months ago
Richard Van Wagoner 3 months ago
Richard Van Wagoner 3 months ago
Kevin Robertson 3 months ago
Check the name of your Subform object.
Richard Van Wagoner 3 months ago
Here is a screenshot of what I have
Richard Van Wagoner 3 months ago
Richard Van Wagoner 3 months ago
I saw one problem with SubformID, so I changed it. Now I get this error message. I did watch the Intro to VBA video last night and the extended cut video. I have a little better understanding of what is going on now.
Richard Van Wagoner 3 months ago
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.