CancelEvent code issue

  • Thread starter Thread starter robertfuschetto via AccessMonster.com
  • Start date Start date
R

robertfuschetto via AccessMonster.com

On an Access Report, on the 'On Format' for a footer, I want to suppress the
footer when: table.item = 'suppress'. I figure I need to use the DoCmd.
CancelEvent but I am unsure how to procede. I assume I use the code builder
to build the event but I am not sure how to code up my If condition.
 
Notice in the Function definition, there is a Cancel argument. All you have
to do is:

If table.item = "suppress" Then
Cancel = True
End If
 
I am sorry, when I look at the help for CancelEvent it says it has no
arguments. I feel as though I am missing something staring me in the face.
You are talking about DoCmd.CancelEvent or some other Cancel funstion.

Thanks much.
 
I am talking about the Report Footer Format event. Notice its definition:
Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)
^^^^
It is the Cancel argument you need to use here.

If table.item = "suppress" Then
Cancel = True
End

Setting Cancel to True causes the report to ingore formatting for the
current record.
 
The following code yeilds a Run Time 424 - Object Required Error. I assure
you the table and field name are correct.


Private Sub GroupFooter5_Format(Cancel As Integer, FormatCount As Integer)
If tblPhysicianProfileReportData.EncounterType = "none" Then
Cancel = 1
End If
End Sub

Ideas?
I am talking about the Report Footer Format event. Notice its definition:
Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)
^^^^
It is the Cancel argument you need to use here.

If table.item = "suppress" Then
Cancel = True
End

Setting Cancel to True causes the report to ingore formatting for the
current record.
Notice in the Function definition, there is a Cancel argument. All you have
to do is:
[quoted text clipped - 7 lines]
 
Yes, What is tblPhysicianProfileReportData.EncounterType ?
If you are trying to reference a field in a table here, that is not correct.
You need to be looking at a control on your report. The only way your code
would be correct is if you had a recordset open and you had
tblPhysicianProfileReportData identified as the recordset name. Even then,
it would see .EncounterType as a property, not as a field. If it were a
field it should be referenced as !EncounterType.

One other thing, Use Cancel = True rather than Cancel = 1. That is not
causing the error, but it is better coding practice. The above reference to
tblPhysicianProfileReportData.EncounterType is the problem.

robertfuschetto via AccessMonster.com said:
The following code yeilds a Run Time 424 - Object Required Error. I assure
you the table and field name are correct.


Private Sub GroupFooter5_Format(Cancel As Integer, FormatCount As Integer)
If tblPhysicianProfileReportData.EncounterType = "none" Then
Cancel = 1
End If
End Sub

Ideas?
I am talking about the Report Footer Format event. Notice its definition:
Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)
^^^^
It is the Cancel argument you need to use here.

If table.item = "suppress" Then
Cancel = True
End

Setting Cancel to True causes the report to ingore formatting for the
current record.
Notice in the Function definition, there is a Cancel argument. All you have
to do is:
[quoted text clipped - 7 lines]
CancelEvent but I am unsure how to procede. I assume I use the code builder
to build the event but I am not sure how to code up my If condition.
 
Yes I was referencing a table item not a report item. I think its working
now...THANKS!!!!!!!!!!!!!!!!!!!!!
Yes, What is tblPhysicianProfileReportData.EncounterType ?
If you are trying to reference a field in a table here, that is not correct.
You need to be looking at a control on your report. The only way your code
would be correct is if you had a recordset open and you had
tblPhysicianProfileReportData identified as the recordset name. Even then,
it would see .EncounterType as a property, not as a field. If it were a
field it should be referenced as !EncounterType.

One other thing, Use Cancel = True rather than Cancel = 1. That is not
causing the error, but it is better coding practice. The above reference to
tblPhysicianProfileReportData.EncounterType is the problem.
The following code yeilds a Run Time 424 - Object Required Error. I assure
you the table and field name are correct.
[quoted text clipped - 24 lines]
 
Back
Top