Results 1 to 3 of 3
  1. #1
    jaworski_m is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2015
    Posts
    25

    Runtime error 2465 although a field in report's record source defined

    Hello,

    I would like to hide/display some fields on a report when it is open basing on the value in [currencyName] field. The field is already defined in the report's record source. The definition is OK as the field is displayed correctly on the report when no VBA is run.
    The field is located in report's heading.



    Once the code is run I get the following error: "Runtime error 2465 report can't find the field currencyName" which is triggered by the first line of the IF statament.

    Code:
        
    If Me.currencyName = "EUR" Then
     ' do something
     End If
    I tried to put the code in different locations (report event, heading event) and also tried referencing the field using "Report!...." syntax but still get the same error

    I do not know why the error is displayed and how to fix it.
    Thank you for any hints.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    This would be setting Visible property of controls. Code must be in the OnFormat event of the section the controls are in. OnFormat event triggers only when direct to print or Print Preview, not Report View.

    Even though controls are not visible, they still occupy space.

    What controls do you want to hide and why?
    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.

  3. #3
    jaworski_m is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2015
    Posts
    25
    Code must be in the OnFormat event of the section the controls are in. OnFormat event triggers only when direct to print or Print Preview, not Report View.
    This worked.
    Thank you.


    Additionally, I made a simple mistake in my way of thinking while writing VBA.
    I was referefing to field's source, yet I had to refer to field's name, which was different.

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

Similar Threads

  1. Replies: 3
    Last Post: 10-10-2014, 06:29 PM
  2. runtime error 2465 'l1'
    By mike02 in forum Forms
    Replies: 5
    Last Post: 07-17-2013, 03:37 PM
  3. Replies: 1
    Last Post: 12-01-2012, 12:44 PM
  4. Replies: 5
    Last Post: 06-09-2012, 12:37 PM
  5. Run Time Error 2465 In Report
    By desk4tbc in forum Programming
    Replies: 9
    Last Post: 09-06-2011, 08:00 PM

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