By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,165 Members | 1,089 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,165 IT Pros & Developers. It's quick & easy.

How to tell if a form is opened as a tab (Access 2007)

P: n/a
Access 2007 optionally opens forms as tabs. There is an Access Option
that controls this - Access Options Current Database Document
Window Options Tabbed Documents.

But how, from VBA, can I programmatically tell whether or not a form
is opened in Tabbed or Overlapping mode?

I tried using

Application.GetOption("Document Window Options")

....but that is apparently an invalid name. There appears to be no form
property that indicates what mode it is opened in.

Can anyone help?

Thanks,

Peter

Mar 3 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On 3 Mar 2007 11:12:03 -0800, "Peter" <in**@peterssoftware.comwrote:

I don't have A2007 handy here, but in previous versions the text to
use for the various options was documented in the help file.
-Tom.

>Access 2007 optionally opens forms as tabs. There is an Access Option
that controls this - Access Options Current Database Document
Window Options Tabbed Documents.

But how, from VBA, can I programmatically tell whether or not a form
is opened in Tabbed or Overlapping mode?

I tried using

Application.GetOption("Document Window Options")

...but that is apparently an invalid name. There appears to be no form
property that indicates what mode it is opened in.

Can anyone help?

Thanks,

Peter
Mar 3 '07 #2

P: n/a
Thanks Tom, but I've looked through the help file and found nothing
about the Get/SetOption for Document Window Options, Overlapping
Windows, or Tabbed Documents.

Mar 3 '07 #3

P: n/a
On Mar 3, 11:12 am, "Peter" <i...@peterssoftware.comwrote:
Access 2007 optionally opens forms as tabs. There is an Access Option
that controls this - Access Options Current Database Document
Window Options >Tabbed Documents.

But how, from VBA, can I programmatically tell whether or not a form
is opened in Tabbed or Overlapping mode?

I tried using

Application.GetOption("Document Window Options")

...but that is apparently an invalid name. There appears to be no form
property that indicates what mode it is opened in.

Can anyone help?

Thanks,

Peter
Still looking for a solution here... Does anyone have an idea?

The help file seems to indicate that I can use

Application.GetOption("Document Window Options")

.... and it will return an integer value representing the option
selected below the "Document Window Optons" heading, but Access comes
back with the "invalid name" error.

It would be nice to know what mode (tabbed documents, or overlapping
windows) my form is opened in from VBA code.

Thanks,

Peter

Mar 5 '07 #4

P: n/a
Well, I've come up with this function as a work-around. A tabbed form
should be the same size as the Access window client area, so this
function checks for that:

Private Declare Function apiGetWindowRect Lib "user32" Alias
"GetWindowRect" (ByVal hWnd As Long, lpRect As sel_rect) As Long

Private Declare Function apiFindWindowEx Lib "user32" Alias
"FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String _
, ByVal lpsz2 As String) As Long
Private Function xg_IsTabbed(frm As Form) As Boolean
'* Returns True if the passed form is opened as an Access 2007 tabbed
form
'* A tabbed form will be the same size as the Access window client
area
'* Requires the GetWindowRect and FindWindowEx APIs
Dim Marker As Integer
Dim Rtn As Boolean
Dim l As Long
Dim ClientRect As sel_rect
Dim frmRect As sel_rect
Dim AccessMDIClientHwnd As Long
On Error GoTo Err_Section
Marker = 1

l = apiGetWindowRect(frm.hWnd, frmRect)
AccessMDIClientHwnd = apiFindWindowEx(Access.hWndAccessApp, 0&,
"MDIClient", vbNullString)
l = apiGetWindowRect(AccessMDIClientHwnd, ClientRect)

If frmRect.Left = ClientRect.Left _
And frmRect.Right = ClientRect.Right _
And frmRect.Top = ClientRect.Top _
And frmRect.Bottom = ClientRect.Bottom Then
'* The form size is the same size as the client area - it must
be an Access 2007 tabbed form
Rtn = True
Else
Rtn = False
End If

Exit_Section:
On Error Resume Next
xg_IsTabbed = Rtn
On Error GoTo 0
Exit Function
Err_Section:
Select Case Err
Case Else
Beep
MsgBox "Error in xg_IsTabbed (" & Marker & "), object " &
Err.Source & ": " & Err.Number & " - " & Err.Description
End Select
Err.Clear
Resume Exit_Section
End Function

Mar 6 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.