Results 1 to 7 of 7
  1. #1
    sanderson is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Posts
    64

    Which Report Event do I use?

    Hello:

    I am trying to get a report to use data on a form, and need to know which report event to put this information on. I am getting all kinds of setfocus errors and other things.




    Code:
        If Forms!frmTimeCard.txtSS = 1 Then
            txtSupID.ControlSource = Forms!frmTimeCard.txtEmpID
            
        Else
            txtSupID.ControlSource = Forms!frmTimeCard.txtcharacter06
                    
        End If
    Thanks!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    To set a control source I'd use the open event, but is that what you're doing? Do the form controls contain field names? Or are you trying to use the form values in the report? If so I'd use the load event or the format event of the section containing txtSupID.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    sanderson is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Posts
    64
    I tried the format event on the report page header, which produces runtime error 2191, cannot set the control source property in print preview or after printing has started.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Cannot set ControlSource property of textbox on report (can on form).

    If you want the values from the form controls, expression in textbox ControlSource:

    =IIf(Forms!frmTimeCard.txtSS = 1, Forms!frmTimeCard.txtEmpID, Forms!frmTimeCard.txtcharacter06)

    But why do you need to do this? What is txtcharacter06?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Quote Originally Posted by June7 View Post
    Cannot set ControlSource property of textbox on report (can on form).
    Not true, though I don't know if it's required here.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Quote Originally Posted by sanderson View Post
    I tried the format event on the report page header, which produces runtime error 2191, cannot set the control source property in print preview or after printing has started.
    Are you trying to set the control source to a different field name, or just put a value in the textbox. If the latter:

    txtSupID.Value = Forms!frmTimeCard.txtcharacter06
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    DrGUI is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Location
    Parts Unknown
    Posts
    23
    Try the following:

    If Forms!frmTimeCard.txtSS = 1 Then
    txtSupID.value = Forms!frmTimeCard.txtEmpID
    Else
    txtSupID.value = Forms!frmTimeCard.txtcharacter06
    End If

    I am assuming that the txtSupID are text boxes in the Detail section of your report. If that is the case, put your code in the Detail_Format event of the report.

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

Similar Threads

  1. Report Format Event
    By Alex Motilal in forum Programming
    Replies: 4
    Last Post: 08-26-2015, 10:30 PM
  2. On Load Event for report
    By zburns in forum Programming
    Replies: 10
    Last Post: 05-12-2015, 12:38 PM
  3. Event program as MS Access report
    By ltech78 in forum Reports
    Replies: 1
    Last Post: 05-31-2014, 11:03 AM
  4. Replies: 37
    Last Post: 03-15-2014, 03:30 PM
  5. Triggering a form event from a report
    By Paul H in forum Forms
    Replies: 2
    Last Post: 10-12-2012, 09:48 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