Results 1 to 6 of 6
  1. #1
    lbcarvalho is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jul 2018
    Posts
    31

    How to get the value from a report and show it in a form without opening the report

    Hi,

    I have a DB with a form as the Main Menu and a value calculated into a text box in a report.

    I would like to see this value in the Main Menu form.

    I have already managed to do that, but the value shows only when I open the report. If you don't open the report, the form box value shows as #Error.

    I used this formula to get the value: =[Reports]![ITABalance]![Text39].

    How do I get the value to appear in the Main Menu form without opening the report?

    Thanks in advance for any hint to solve this problem.

    lbcarvalho

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Can you do the computation/calculation using vba? If so, you do that when the form is open and display the value on the form.
    Reports are typically meant for output; printing; display -- not usually as an input source for populating a control on a form.

  3. #3
    lbcarvalho is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jul 2018
    Posts
    31
    This is what I tried:

    Private Sub Form_Open(Cancel As Integer)


    Me.txtBAL_IN_MAIN_MENU = [Reports]![ITA_BALANCE]![Text39]


    End Sub

    But all I get is an error message: Run-Time error 2465. Can't find the field '1' referred to in your expression



  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    I think what Orange meant was to redo the calculation that you do in the report in the main form, realizing that it might not be the exact same formula as you might need to use domain aggregate functions like dsum, dcount and your reports record source. The short answer is no, cannot reference a control on a report that is not open.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  5. #5
    Join Date
    Apr 2017
    Posts
    1,792
    It is really simple! As report results exists only when report is opened, then they don't exist when report is not opened :-)

    Of course you can make same calculations in form and got the wanted result.

  6. #6
    Bullschmidt's Avatar
    Bullschmidt is offline Freelance DB Developer
    Windows 10 Office 365
    Join Date
    Mar 2020
    Location
    USA
    Posts
    64
    Or I guess you COULD actually have code behind the form's OnActivate or OnOpen that opens the report and then run code like this to set the focus back to the form:
    Me.SetFocus

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

Similar Threads

  1. Replies: 8
    Last Post: 08-15-2019, 02:49 PM
  2. Replies: 1
    Last Post: 05-27-2013, 08:54 AM
  3. Opening a report from a form command
    By undee69 in forum Reports
    Replies: 4
    Last Post: 01-13-2013, 08:57 AM
  4. Replies: 1
    Last Post: 01-10-2012, 03:44 AM
  5. Opening Report From Form
    By injanib in forum Forms
    Replies: 4
    Last Post: 02-08-2011, 08:44 AM

Tags for this Thread

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