Results 1 to 11 of 11
  1. #1
    zolazree is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2016
    Posts
    8

    How to retrieve data from a subform and display it in the main form?


    So basically, I'm trying to retrieve the SUM of the data (refer image below) from the field "TotalPrice" (highlighted red) in the subform and put it into the "Sales" (highlighted blue) field in the main form. I've tried a few things including using the DLOOKUP function, but then the "Sales" field but that didn't work as I wanted it to. I'm really quite new to MS Access and I hope someone can help me with this for my school assignment. Thanks!



    Click image for larger version. 

Name:	Access.PNG 
Views:	28 
Size:	20.8 KB 
ID:	26077

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    The easiest way is to let the SubForm do its own total in the footer of the SubForm and then let your main form control get it using this syntax: http://access.mvps.org/access/forms/frm0031.htm

  3. #3
    zolazree is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2016
    Posts
    8
    I dont know how to delete this

  4. #4
    zolazree is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2016
    Posts
    8
    Quote Originally Posted by RuralGuy View Post
    The easiest way is to let the SubForm do its own total in the footer of the SubForm and then let your main form control get it using this syntax: http://access.mvps.org/access/forms/frm0031.htm
    Hi RuralGuy,
    I'm having trouble understanding which syntax that I'm supposed to use and how do I type it in the design of my forms.
    Would you kindly help me out by showing me exactly how to do it?
    Thanks !

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    The control source of the control in the Main Form would look like:
    = SubFormControlName.FORM.SubFormName.ControlName

    In the link I provided it is described as:
    Me!Subform1.Form!ControlName
    ...where in fact there are several forms of the syntax that work.

  6. #6
    zolazree is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2016
    Posts
    8
    Quote Originally Posted by RuralGuy View Post
    The control source of the control in the Main Form would look like:
    = SubFormControlName.FORM.SubFormName.ControlName

    In the link I provided it is described as:
    Me!Subform1.Form!ControlName
    ...where in fact there are several forms of the syntax that work.
    I'm sorry RuralGuy, but I just can't seem to make it work .
    Errors keep happening, & I don't know what I did wrong...
    Do I just type in the syntax u gave above into the Unbound field (blue) if I want the SUM of the TotalPrice field from the subform (red)?

    Maybe you could tell me more about what the "Me!" function does or is it even a 'function', or what does the "SubForm1.Form" or the "ControlName" represents. Do I change it to something in my database? Is the 'SubForm1' supposed to be the name of the subform, and is the 'ControlName' the name of the field in the subform that I want to retrieve (for my case, the 'TotalPrice' field?).

    I'm sorry man, I've no clue what I'm supposed to do.


    Click image for larger version. 

Name:	Capture.PNG 
Views:	22 
Size:	30.5 KB 
ID:	26373
    Attached Thumbnails Attached Thumbnails Capture.PNG  

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    What is the name of your SubFormControl? Not the SubForm that it displays but the name of the control that displays it?
    What is the name of the control on your SubForm that displays the TotalPrice?

  8. #8
    zolazree is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2016
    Posts
    8
    Quote Originally Posted by RuralGuy View Post
    What is the name of your SubFormControl? Not the SubForm that it displays but the name of the control that displays it?
    What is the name of the control on your SubForm that displays the TotalPrice?
    Its name on the SubForm is 'TotalPrice'

  9. #9
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    If you want the correct syntax you will need to answer all of the questions I asked.
    I will take a guess and say:
    = Me!TotalPrice.Form!TotalPrice
    ...again, you need the CorrectNames in these two positions.

  10. #10
    zolazree is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2016
    Posts
    8
    Quote Originally Posted by RuralGuy View Post
    If you want the correct syntax you will need to answer all of the questions I asked.
    I will take a guess and say:
    = Me!TotalPrice.Form!TotalPrice
    ...again, you need the CorrectNames in these two positions.
    Hey, RuralGuy. Thanks a lot man. I finally figured it out. The expression I used was, =[tSalesSubform1].[Form]![InvoiceTotal].
    I'm starting to get the hang of all this now. Sorry if I didn't understand some of what u said earlier on. Thanks again!

  11. #11
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Excellent! Glad you figured it out.

    I marked this thread as *Solved* for you, using the *Thread Tools* at the top of the thread.
    https://www.accessforums.net/showthread.php?t=1828

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 08-19-2015, 08:32 PM
  2. Display subtotal from subform in main form
    By dougdrex in forum Forms
    Replies: 5
    Last Post: 11-12-2014, 03:25 PM
  3. How to display multiple Subform in main form
    By selvakumar.arc in forum Forms
    Replies: 5
    Last Post: 05-06-2013, 11:42 AM
  4. Replies: 2
    Last Post: 06-17-2010, 04:15 PM
  5. Subform won't display in main form
    By Lynn in forum Forms
    Replies: 15
    Last Post: 03-22-2010, 10:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums