Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

An Easy - On Format Problem

Status
Not open for further replies.

skyhighe

Technical User
May 16, 2001
7
US
This one should be a drop dead no brainer... I must have mind lock... I can't seem to think this one through. I have a standard (I built it) query which provides records to a report. I have 2 possiblities for a Physician's name depending on the financial group that the patient belongs to. If a couple of fields are certain values then I want the secondary physican's name shown other wise I want to show the attending physician.

I think it should look something like this and I have put it in the On_Format event of the detail line of the report:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If ([AUTHENT_STATUS] = &quot;S&quot; And ([FINCLASS_GROUP_ID] > 0 And [FINCLASS_GROUP_ID] < 4)) Or ([AUTHENT_STATUS] = &quot;M&quot;) Then
Me!Physician_last_name = SEC_PROVIDER_NAME_LAST
Else
Me!Physician_last_name = ATT_PROVIDER_NAME_LAST
End If
End Sub


The problem is that I must not be using the right naming convention (told you it was simple) cause when I run the report it does not recognize any of the names of the fields in the query... Can someone steer me in the right direction please.

Mega Thanks in Advance

 
The problem is, what you have typed is not a query but a code procedure. You cannot actually just refer to fields in a procedure without first setting up a recordset (see OpenRecordset method in Help). You can use an SQL query as the argument for the OpenRecordset method so that the recordset returns the records you want. Have fun! :eek:)

Alex Middleton
 
I already have a query that is the data source of this report. Can't I use the fields in the query (if they are checked to be visible) to make decisions on in the code. And then put the code in the ON_FORMAT event of the detail section of the report?

Thanks..

Skyhighe
 
I don't believe you can reference fields in your record source query unless those fields are also present on the report itself. When I need to reference fields that are in my recordsource, but which I don't need displayed on the report I add them as tiny textboxes to the report and make their visible property false. You can then reference the report fields directly. Maq [americanflag]
<insert witty signature here>
 
That's exactly what I do too, Maq. Works a treat. Have fun! :eek:)

Alex Middleton
 
I have tried that and it might be working but it still is telling me that it cant find a field. Unfortunately it doesn't list the field name it just lists a pipe as the field name and gives me error 2465.

One of the fields that I am trying to reference is in a header. This is a patient system and we read in the patient data and then list the treatments below. I need to reference that patient's financial class in the decision at the detail level... I think that the field that it cant find is the one I am referencing in the Patient header...

Could you steer me in the right direction?

Giga-Thanks
 
Have you double checked all your spelling and field names in the code. Sounds like you may have miskeyed a field name. (Remember you want the name of the field on the report, not the name of the field in the table/query if they're different.)

Other than that, it's pretty hard to debug your problem without seeing your code. And I don't know what an error 2465 is. I haven't gotten around to memorizing all the error numbers yet. [reading] Maq [americanflag]
<insert witty signature here>
 
I want to take the time to thank all who responded and helped me here....

I appreciate your knowledge, the willingness to share, and your helpful spirt...


Houston... We have lift off!!!!


Skylar Highe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top