code in report doesn't see field in record source

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a report that is printed from a form. The record source for the
report is a query that includes all the fields needed for the report. I have
a text box that needs to be filled in based on the value of a field called
STATUS. I have code in the detail_print event to set this value. When I run
the report it gives me error 2465 and tells me that it can't find the field
STATUS. When I run the query by itself, the field is clearly there in the
result.

Originally I had this field in the Pageheader_print event. I thought the
problem might be one of timing, so I moved it to the detail event, but I
still get the error.

I don't think that the code is the problem, but here it is:

Select Case Me.status
Case "W"
txtstatus = "Waiting for Supervisor Approval"
Case "S"
txtstatus = "waiting for Purchasing Approval"
Case "P"
txtstatus = "waiting for Finance Director Approval"
Case "A"
txtstatus = "Approved"
Case Else
txtstatus = "not submitted"
End Select
 
You must have the Status field bound to a control in the report section. It
doesn't need to be visible.

I would think you could use a status lookup table in your report's record
source and get rid of your code. You should not be "hard-coding" values like
this. For instance, what happens WHEN you get another status value? Are you
going to have to maintain code or can you simply maintain data?
 
Thank you! That fixed the problem. Thanks for your other suggestion - I
agree that this probably should be table driven.
 
Back
Top