acView read property

  • Thread starter Thread starter yoda jedi
  • Start date Start date
Y

yoda jedi

I need to be able to read whether or not a report has been launched in
normal mode or preview mode.

I have been looking through the report properties and don't see
anything.

DoCmd.OpenReport "Whatever Report", acViewPreview

And then in the Whatever report, the macro code, I would want to know
that it was launched in Preview mode, so I would want to query
Me.WhatModeWasThisReportLaunchedFor?

Or something along those lines.
Thanks,
JJ
(e-mail address removed)
 
yoda said:
I need to be able to read whether or not a report has been launched in
normal mode or preview mode.

I have been looking through the report properties and don't see
anything.

DoCmd.OpenReport "Whatever Report", acViewPreview

And then in the Whatever report, the macro code, I would want to know
that it was launched in Preview mode, so I would want to query
Me.WhatModeWasThisReportLaunchedFor?

THere is no property for this. The report's Activate event
only fires when the report is being previewed, so this can
be used to set your own variable as an indicator for print
or preview:

Dim booPreview As Boolean

Sub Report_Activate(
booPreview = True
End Sub

Later in the report's event sequence, you can test the
variable:

If booPreview Then
' opened in preview
Else
' opened in normal
End If

Remember that the standard print preview toolbar has a Print
button, so, unless you customize the toolbar, user's can
still print a copy of the report without your code being
aware of it.
 
Marshall Barton said:
THere is no property for this. The report's Activate event
only fires when the report is being previewed, so this can
be used to set your own variable as an indicator for print
or preview:

Dim booPreview As Boolean

Sub Report_Activate(
booPreview = True
End Sub

Later in the report's event sequence, you can test the
variable:

If booPreview Then
' opened in preview
Else
' opened in normal
End If

Remember that the standard print preview toolbar has a Print
button, so, unless you customize the toolbar, user's can
still print a copy of the report without your code being
aware of it.


Hi, I read it somewhere that the Activate event only fires when the
report is being previewed... however... the Activate event seems to be
firing no matter what.

I originally tried your solution. The Activate event doesn't seem to
be paying attention to what mode I'm running in. So it's either a
worldwide conspiracy to lie to me about this particular issue OR ...
or what?

The basic idea of the code below is to send the user to reports A or B
depending on what company they are running for. Company A, use
ThirdParty Report_A, B uses ThirdParty Report_B, all else uses the
regular ThirdParty Report.

In order to do this, I have to 1) print out the right report 2)
suppress the wrong report. And I'm having major troubles doing this
very simple thing.

Option Compare Database
Option Explicit
Public strCompany As String

Private Sub Report_Activate()
Select Case UCase(Trim(strCompany))
Case "PATCHLINK", "BEGINFINITE"
DoCmd.Close acReport, "ThirdParty Report"
Case Else
End Select
End Sub

Private Sub Report_Open(Cancel As Integer)
Dim rsQuery As Recordset
Dim dStartDate, dEndDate As Date
Dim lview As Integer

Set rsQuery = DBEngine.Workspaces(0).Databases(0).OpenRecordset( _
"SELECT * FROM tThirdPartyReport_Params")

lview = acViewPreview

If Not rsQuery.EOF Then
dStartDate = rsQuery!StartDate
dEndDate = rsQuery!EndDate
strCompany = rsQuery!Company
End If

Select Case UCase(Trim(strCompany))
Case "A"
DoCmd.OpenReport "ThirdParty Report_A", lview
Case "B"
DoCmd.OpenReport "ThirdParty Report_B", lview
Case Else
End Select
End Sub
 
Marshall Barton said:
THere is no property for this. The report's Activate event
only fires when the report is being previewed, so this can
be used to set your own variable as an indicator for print
or preview:

Dim booPreview As Boolean

Sub Report_Activate(
booPreview = True
End Sub

Later in the report's event sequence, you can test the
variable:

If booPreview Then
' opened in preview
Else
' opened in normal
End If

Remember that the standard print preview toolbar has a Print
button, so, unless you customize the toolbar, user's can
still print a copy of the report without your code being
aware of it.


Hi, I read it somewhere that the Activate event only fires when the
report is being previewed... however... the Activate event seems to be
firing no matter what.

I originally tried your solution. The Activate event doesn't seem to
be paying attention to what mode I'm running in. So it's either a
worldwide conspiracy to lie to me about this particular issue OR ...
or what?

The basic idea of the code below is to send the user to reports A or B
depending on what company they are running for. Company A, use
ThirdParty Report_A, B uses ThirdParty Report_B, all else uses the
regular ThirdParty Report.

In order to do this, I have to 1) print out the right report 2)
suppress the wrong report. And I'm having major troubles doing this
very simple thing.

Option Compare Database
Option Explicit
Public strCompany As String

Private Sub Report_Activate()
Select Case UCase(Trim(strCompany))
Case "A", "B"
DoCmd.Close acReport, "ThirdParty Report"
Case Else
End Select
End Sub

Private Sub Report_Open(Cancel As Integer)
Dim rsQuery As Recordset
Dim dStartDate, dEndDate As Date
Dim lview As Integer

Set rsQuery = DBEngine.Workspaces(0).Databases(0).OpenRecordset( _
"SELECT * FROM tThirdPartyReport_Params")

lview = acViewPreview

If Not rsQuery.EOF Then
dStartDate = rsQuery!StartDate
dEndDate = rsQuery!EndDate
strCompany = rsQuery!Company
End If

Select Case UCase(Trim(strCompany))
Case "A"
DoCmd.OpenReport "ThirdParty Report_A", lview
Case "B"
DoCmd.OpenReport "ThirdParty Report_B", lview
Case Else
End Select
End Sub
 
yoda said:
Hi, I read it somewhere that the Activate event only fires when the
report is being previewed... however... the Activate event seems to be
firing no matter what.

I originally tried your solution. The Activate event doesn't seem to
be paying attention to what mode I'm running in. So it's either a
worldwide conspiracy to lie to me about this particular issue OR ...
or what?

The basic idea of the code below is to send the user to reports A or B
depending on what company they are running for. Company A, use
ThirdParty Report_A, B uses ThirdParty Report_B, all else uses the
regular ThirdParty Report.

In order to do this, I have to 1) print out the right report 2)
suppress the wrong report. And I'm having major troubles doing this
very simple thing.

Option Compare Database
Option Explicit
Public strCompany As String

Private Sub Report_Activate()
Select Case UCase(Trim(strCompany))
Case "A", "B"
DoCmd.Close acReport, "ThirdParty Report"
Case Else
End Select
End Sub

Private Sub Report_Open(Cancel As Integer)
Dim rsQuery As Recordset
Dim dStartDate, dEndDate As Date
Dim lview As Integer

Set rsQuery = DBEngine.Workspaces(0).Databases(0).OpenRecordset( _
"SELECT * FROM tThirdPartyReport_Params")

lview = acViewPreview

If Not rsQuery.EOF Then
dStartDate = rsQuery!StartDate
dEndDate = rsQuery!EndDate
strCompany = rsQuery!Company
End If

Select Case UCase(Trim(strCompany))
Case "A"
DoCmd.OpenReport "ThirdParty Report_A", lview
Case "B"
DoCmd.OpenReport "ThirdParty Report_B", lview
Case Else
End Select
End Sub


I presume that this code is in the standard ThirdParty
Report?? If so, I don't see how the Preview mode comes into
it?? Even if it does, I am wondering why you're opening one
report just so it can choose to close itself after opening a
different report.

A more standard way to conditionally choose which report to
run is to use a form button to print or preview the desired
report without all this fooling around. The button's click
event would be very much like the code you already have:

Private Sub Report_Open(Cancel As Integer)
Dim rsQuery As Recordset
Dim dStartDate, dEndDate As Date
Dim lview As Integer

Set rsQuery =
DBEngine.Workspaces(0).Databases(0).OpenRecordset( _
"SELECT * FROM tThirdPartyReport_Params")

lview = acViewPreview

If Not rsQuery.EOF Then
dStartDate = rsQuery!StartDate
dEndDate = rsQuery!EndDate
strCompany = rsQuery!Company
End If

Select Case UCase(Trim(strCompany))
Case "A"
DoCmd.OpenReport "ThirdParty Report_A", lview
Case "B"
DoCmd.OpenReport "ThirdParty Report_B", lview
Case Else
DoCmd.OpenReport "ThirdParty Report", lview
End Select
End Sub

but, since this only opens the desired report, the report
does not have to concern itself with any of this stuff
(except possibly for the start and end date values).
 
The problem is that I don't want to change the VB Project code. I may
have to, but I don't want to. The reason for this is that the code is
generic. I mean that there are 10 to 15 reports running the same
code.

So the idea was to sort of redirect the reports, based on parameters
saved in the table ThirdParty_Params.

So no matter what company you were with, if you ran the Third Party
Report, it would open the ThirdParty Report, but then it would check
the params, and if you were company A or B, close the ThirdParty
Report and open the ThirdParty Report_A or ThirdParty Report_B.

It works fine for Print Preview. However, for printing, it will
preview the A or B report and then print the original report, which is
the ThirdParty Report, which doesn't necessarily apply to companies A
or B.

The other thing I thought of, but I don't know how to do, is to have
Page Header, Page Header A and Page Header B, and Detail, Detail A,
and Detail B. But this seems to involve these things called Macros,
which I don't know what they are. Could I possibly, using the global
company variable, check the company and then route the report through
Page Header B, Details B, Footer B, etc????????????

Thanks for your help so far, Marshall. When I started out, I simply
assumed that there would be some way to simply say,
Me.Report.Change(A) or something foolish like that. It seems
laughable and naive now.

JJ
John Jacobs
"Paid Employee"
Authentium / Command Software
www.authentium.com
 
yoda said:
The problem is that I don't want to change the VB Project code. I may
have to, but I don't want to. The reason for this is that the code is
generic. I mean that there are 10 to 15 reports running the same
code.

So the idea was to sort of redirect the reports, based on parameters
saved in the table ThirdParty_Params.

So no matter what company you were with, if you ran the Third Party
Report, it would open the ThirdParty Report, but then it would check
the params, and if you were company A or B, close the ThirdParty
Report and open the ThirdParty Report_A or ThirdParty Report_B.

It works fine for Print Preview. However, for printing, it will
preview the A or B report and then print the original report, which is
the ThirdParty Report, which doesn't necessarily apply to companies A
or B.

You might be able to maqke that work, but you can't use the
Activate event because it only fires when the report is
previewed. Try using the Open event, probably not quite
that simple but see what happens.

The other thing I thought of, but I don't know how to do, is to have
Page Header, Page Header A and Page Header B, and Detail, Detail A,
and Detail B. But this seems to involve these things called Macros,
which I don't know what they are.

Forget about macros, you can do more things more easily (or
at least more clearly) using VBA.

Could I possibly, using the global
company variable, check the company and then route the report through
Page Header B, Details B, Footer B, etc????????????

Don't what you might be thinking of by "route through Page
Header . . ."

OTOH, you can use code to modify the report's record source,
the fields the controls are bound to, the position of the
controls, and many other settings. If you can do this and
If so, how depends on the variations between the different
versions of the reports. If the differences are not too
drastic and you feel like pursuing this approach, post back
with a list of of the variations and we'll see what can be
done.
 
I've tried pretty much everything. Access seems to know whether a
report is going to be previewed or printed, but such information
doesn't seem accessible in the code. So it's tantalizingly simple,
but I can't get at it.

By route, I meant, if a user is running the report for company A,
compose the report with appropriate sections, Report Header A, Page
Header A, Details A, etc. If the user is running the report for
company B, Report Header B, Page Header B, etc.

See, you know the game, people upstairs want you to make a few changes
to a report, only for companies A and B. All other companies ... no
change.

So the task is 3 reports with no change in the user interface. Right
now, we have a drop down with the company names (this is a VB app),
and a radio button for preview / print, and a "Run" button, and that
can't change.

So thanks for your help so far, but I'm stumped. I can't decide which
I like less, Access or Crystal. At least in Crystal Reports, things
are POSSIBLE!
 
yoda said:
I've tried pretty much everything. Access seems to know whether a
report is going to be previewed or printed, but such information
doesn't seem accessible in the code. So it's tantalizingly simple,
but I can't get at it.

By route, I meant, if a user is running the report for company A,
compose the report with appropriate sections, Report Header A, Page
Header A, Details A, etc. If the user is running the report for
company B, Report Header B, Page Header B, etc.

See, you know the game, people upstairs want you to make a few changes
to a report, only for companies A and B. All other companies ... no
change.

So the task is 3 reports with no change in the user interface. Right
now, we have a drop down with the company names (this is a VB app),
and a radio button for preview / print, and a "Run" button, and that
can't change.

So thanks for your help so far, but I'm stumped. I can't decide which
I like less, Access or Crystal. At least in Crystal Reports, things
are POSSIBLE!


I think you're giving up too soon.

Did you try getting away from the Activate event (I still
have no idea why you are using it)? You did say you want
the same thing to happen regardless of print or preview,
didn't you?

If you want to give up on the multiple reports approach and
if you'll explain the details of the differences in the
detail section, headers, etc. for the different companies,
then I am pretty confident that this can be done using a
single report with VBA code that adapts the report to the
company.

For example, if Company A wants to see a field that the
others do not want, then it's just a matter of adding that
text box to the report detail and using VBA to make it
visible or not depending on the company. If some company
wants the report sorted on a different field, then you can
use a few lines of code to change the control source
property of the appropriate GroupLevel.
 
Marshall Barton said:
I think you're giving up too soon.

Did you try getting away from the Activate event (I still
have no idea why you are using it)? You did say you want
the same thing to happen regardless of print or preview,
didn't you?

If you want to give up on the multiple reports approach and
if you'll explain the details of the differences in the
detail section, headers, etc. for the different companies,
then I am pretty confident that this can be done using a
single report with VBA code that adapts the report to the
company.

For example, if Company A wants to see a field that the
others do not want, then it's just a matter of adding that
text box to the report detail and using VBA to make it
visible or not depending on the company. If some company
wants the report sorted on a different field, then you can
use a few lines of code to change the control source
property of the appropriate GroupLevel.


Hmmm... This last paragraph may work.... Back in a second...
JJ
(e-mail address removed)
On the web at: http://www.authentium.com
 
Back
Top