Return current view of report (1 Viewer)

gwunta

Access Junkie
Local time
Today, 09:37
Joined
May 1, 2001
Messages
24
Hi all, just wondering if there is a VBA command that returns the current view of the current active report. I am running code the uses the SetFocus Action, which works fin in Report view, but when I try to go to Print Preview view, Access throws an error stating that the command or action is not available in the current view - and the GetFocus action is the culprit.

I figure I can skip the GetFocus action if I know the Report is in Print Preview mode, hence my asking this question.

Thanks in advance
 

gwunta

Access Junkie
Local time
Today, 09:37
Joined
May 1, 2001
Messages
24
Re: Return current view of report - Solved

OK solved the issue. There is a way to determine the state of any Access database object. MSDN details it only applicable to Access 2003 but I tried it an it works in Access 2007. The code is as follows:

SysCmd(acSysCmdGetObjectState, ac[objectType], [objectName]

Unfortunately this only details if the object is in a new, open, dirty (data has been added but no yet saved) or closed state.

To determine the Current view of an object use the following code:

[ObjectType]([ObjectName).CurrentView

The return type is an integer value that corresponds to the table below:

0 - Design View
1 - Form view (applies to Form objects only)
2 - Datasheet view (applies to Form objects only)
3 - PivotTable view (applies to Form objects only)
4 - PivotChart view (applies to Form objects only)
5 - Preview view (Applies to Reports only)

Hope this helps others
 

Users who are viewing this thread

Top Bottom