Cannot find field referred to

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bhughes2187
    New Member
    • Mar 2008
    • 32

    Cannot find field referred to

    Ok, here is the scoop.

    I have a report that I am designing. Now, the table that the data comes from, has an field called ATTRIBUTE. This field is populated with an R to indicate when a page break should occur. I then have this block of code to condition the page break:

    Code:
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Me![CondPgBreak].Visible = False
    
    If Me![ATTRIBUTE] = "R" Then
     Me![CondPgBreak].Visible = True
     End If
    End Sub
    This works beautifully..

    Now, due to design issues, I have had to add a new field called PAGEFLAG, and now my R references for the page breaks occur in that field. I have updated the query that the report pulls from to add this new field. When I run the query everything is fine. However when I try running the report with the code changed to reflect the new field to use, :

    Code:
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Me![CondPgBreak].Visible = False
    
    If Me![PAGEFLAG] = "R" Then
     Me![CondPgBreak].Visible = True
     End If
    
    End Sub
    I now get a run time error saying that the field in the expression could not be found.

    Exact error is: Graphics.mdb can't find the field 'PAGEFLAG' referred to in your expression. Runtime error 2465


    I am confused... Please help me
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    Hi. From what you say, the most likely explanation is that you have not included the field PAGEFLAG as a control on your report, or if you have included it you have changed its name to something else.

    Me![PAGEFLAG] is interpreted as 'the value of the control named PAGEFLAG on the current report'. It does not mean 'the field called PAGEFLAG in the recordsource query'.

    If there is no control with this name on your report a run-time error will result, as you are finding. If the field is indeed missing drag a copy of the PAGEFLAG field onto your report from the report's field list. If you do not want to print it set its Visible property to No.

    -Stewart

    Comment

    • bhughes2187
      New Member
      • Mar 2008
      • 32

      #3
      Originally posted by Stewart Ross Inverness
      Hi. From what you say, the most likely explanation is that you have not included the field PAGEFLAG as a control on your report, or if you have included it you have changed its name to something else.

      Me![PAGEFLAG] is interpreted as 'the value of the control named PAGEFLAG on the current report'. It does not mean 'the field called PAGEFLAG in the recordsource query'.

      If there is no control with this name on your report a run-time error will result, as you are finding. If the field is indeed missing drag a copy of the PAGEFLAG field onto your report from the report's field list. If you do not want to print it set its Visible property to No.

      -Stewart

      OK Thanks! I must have put the attribute control on there and hid it somehow as I could not find it any where on the design view, it is basically used as a reference point.. I will add the control to the report itself

      Comment

      Working...