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
@Reply 4 years ago
What have you tried to copy the value?
Richard Van WagonerOP
@Reply 4 years ago
Richard Van WagonerOP
@Reply 4 years ago
I tried Forms![ProductTotal]! procedure. I have tried Dlookup.
Kevin Robertson
@Reply 4 years ago
In the Control Source of the field on the Parent form use this syntax:
=[SubformName]![FieldName]
Example: =[OrderDetailF]![SumExtPrice]
Richard Van WagonerOP
@Reply 4 years ago
That is just what I wanted! Thank you!
Kevin Robertson
@Reply 4 years ago
You're welcome.
Richard Van WagonerOP
@Reply 4 years 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 WagonerOP
@Reply 4 years ago
I was checking it is not putting the value in the table.
Kevin Robertson
@Reply 4 years 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 WagonerOP
@Reply 4 years ago
Parent Form is Named ProductF. Subform is ProductDetailF. And the total in subform is SupplySum.
Kevin Robertson
@Reply 4 years 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
@Reply 4 years ago
Richard Van WagonerOP
@Reply 4 years 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 WagonerOP
@Reply 4 years ago
Richard Van WagonerOP
@Reply 4 years ago
Richard Van WagonerOP
@Reply 4 years ago
This is the error message I get when opening the product form.
Kevin Robertson
@Reply 4 years 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
@Reply 4 years ago
Yes. See the screenshot I posted above. With the red square.
Richard Van WagonerOP
@Reply 4 years ago
Richard Van WagonerOP
@Reply 4 years ago
Richard Van WagonerOP
@Reply 4 years 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
@Reply 4 years ago
That's the Expression Builder. You need the Code Builder.
Kevin Robertson
@Reply 4 years ago
Kevin Robertson
@Reply 4 years ago
Richard Van WagonerOP
@Reply 4 years 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 WagonerOP
@Reply 4 years ago
Richard Van WagonerOP
@Reply 4 years ago
Is this the right place?
Kevin Robertson
@Reply 4 years ago
Did you remove all the code you entered previously?
Kevin Robertson
@Reply 4 years ago
Yes. Now enter the code between the Private Sub and End Sub.
Richard Van WagonerOP
@Reply 4 years 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
@Reply 4 years 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 WagonerOP
@Reply 4 years ago
I tried what you said and still an error. see images.
Richard Van WagonerOP
@Reply 4 years ago
Richard Van WagonerOP
@Reply 4 years ago
Richard Van WagonerOP
@Reply 4 years ago
Kevin Robertson
@Reply 4 years ago
Check the name of your Subform object.
Richard Van WagonerOP
@Reply 4 years ago
Here is a screenshot of what I have
Richard Van WagonerOP
@Reply 4 years ago
Richard Van WagonerOP
@Reply 4 years 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 WagonerOP
@Reply 4 years ago
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
TechHelp.