"Tom van Stiphout" <no************ *@cox.netwrote in message
news:lb******** *************** *********@4ax.c om...
On 27 Aug 2006 11:16:49 -0700, "Terry" <te*********@oe l.eclipse.co.uk >
wrote:
You can't, unless you really want to dive into several undocumented
msys* tables.
Better to delete the tables from the diagram, and then select
Relationships All
-Tom.
>>I have added some tables to the MS Access relationship diagram window
(2003) and added some relationships. But after a while when I reopen
the diagram some of the tables are hidden above the top of thewindow
(the relationship lines appear to go way up beyond the upper scroll
limit.
How can I sort them out with out redoing thediagram?
Hi Tom,
if the Relationship Diagram is too complex or too time consuming to recreate
then you can programmaticall y loop through all of the individual windows in
the Relationship window fixing any negative window cordinates you find.
Below is code that only checks and modifies windows off of the left edge of
the screen but it could be easilty modified to check for Vertical negative
coordinates as well.
From: Stephen Lebans - view profile
Date: Tues, Nov 26 2002 6:03 pm
Email: "Stephen Lebans" <StephenLeb...@ mvps.org>
Groups: comp.databases. ms-access
Not yet ratedRating:
show options
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse | Find messages by this author
If for some reason you had a number of relationships that would be
difficult/time consuming to recreate then here is a code fix for this
issue. If you have trouble implementing this code, it is contained
within a Form in the Utilities MDB on my site. Just import the Form into
your app, open the Form and click on the appropriate Command Button.
http://www.lebans.com/utilities.htm
Place the following code behind a Form containing two CommandButton
controls named:
cmdFix
cmdCloseWindow
'DEVELOPED AND TESTED UNDER MICROSOFT ACCESS 97 VBA
'
'Copyright: Stephen Lebans - Lebans Holdings 1999 Ltd.
' Please feel free to use this code within your own projects,
' both private and commercial, with no obligation.
' You may not resell this code by itself or as part of a
collection.
'
'
'Name: None
'
'Version: 1.0
'
'Purpose: 1) To close the Debug Window via code.
' 2) To fix any items in the RelationShips window that are off
screen
'
'Author: Stephen Lebans
'
'Email: Step...@lebans. com
'
'Web Site:
www.lebans.com
'
'Date: July 02 , 2002, 11:11:11 PM
'
'Credits: Your for the taking!<grin>
'
'BUGS: Please report any bugs to:
' Step...@lebans. com
'
'What's Missing:
' Nothing!
'
'How it Works:
' Walk through the source code!<grin>
'
' Enjoy
' Stephen Lebans
Option Compare Database
Option Explicit
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function FindWindow Lib "user32" Alias _
"FindWindow A" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias _
"FindWindow ExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, _
ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function apiGetWindow Lib "user32" _
Alias "GetWindow" _
(ByVal hWnd As Long, _
ByVal wCmd As Long) _
As Long
Private Declare Function apiGetClassName Lib "user32" _
Alias "GetClassNa meA" _
(ByVal hWnd As Long, _
ByVal lpClassName As String, _
ByVal nMaxCount As Long) _
As Long
Private Declare Function GetWindowRect Lib "user32" _
(ByVal hWnd As Long, lpRect As RECT) As Long
Private Declare Function PostMessage Lib "user32" Alias _
"PostMessag eA" (ByVal hWnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Private Declare Function SetWindowPos Lib "user32" _
(ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, _
ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As
Long) As Long
Private Const SWP_NOSIZE = &H1
Private Const WM_CLOSE = &H10
' GetWindow() Constants
Private Const GW_HWNDFIRST = 0
Private Const GW_HWNDLAST = 1
Private Const GW_HWNDNEXT = 2
Private Const GW_HWNDPREV = 3
Private Const GW_OWNER = 4
Private Const GW_CHILD = 5
Private Const GW_MAX = 5
Private Sub cmdCloseWindow_ Click()
' Close the Debug Window via code
On Error GoTo Err_cmdCloseWin dow_Click
Dim lngRet As Long
Dim hWndMDI As Long
Dim hWndDebug As Long
' If this instance of Access has set the
' Debug Window to "Always on Top" via the menu:
' Tools->Options->Module
' then the Debug WIndow is a top level window.
hWndDebug = FindWindow(vbNu llString, "Debug Window")
If hWndDebug <0 Then
lngRet = PostMessage(hWn dDebug, WM_CLOSE, 0&, 0&)
Exit Sub
End If
' The Debug Window is a child of the MDI window
' find MDIClient first
hWndMDI = FindWindowEx(Ap plication.hWndA ccessApp, 0&, "MDIClient" ,
vbNullString)
' Find the Debug Window
hWndDebug = FindWindowEx(hW ndMDI, 0&, "OImmediate ", "Debug Window")
If hWndDebug <0 Then
lngRet = PostMessage(hWn dDebug, WM_CLOSE, 0&, 0&)
Else
MsgBox "The Debug Window is not open."
End If
Exit_cmdCloseWi ndow_Click:
Exit Sub
Err_cmdCloseWin dow_Click:
MsgBox Err.Description
Resume Exit_cmdCloseWi ndow_Click
End Sub
Private Sub cmdFix_Click()
' Fix any windows that are off the Left edge of the RelationShips window
On Error GoTo Err_cmdFix_Clic k
Dim lngRet As Long
Dim hWndMDI As Long
Dim hWndRel As Long
Dim hWndODsk As Long
Dim hWndTemp
Dim rc As RECT
' Force the RelationShips window to open
DoCmd.RunComman d acCmdRelationsh ips
' The window must be maximized
DoCmd.Maximize
DoEvents
' The Relationships Window is a child of the MDI Client window
' find MDIClient first.
hWndMDI = FindWindowEx(Ap plication.hWndA ccessApp, 0&, "MDIClient" ,
vbNullString)
' Find the Relationships Window
hWndRel = FindWindowEx(hW ndMDI, 0&, "OSysRel", "Relationships" )
If hWndRel = 0 Then
MsgBox "The Relationships Window is not open.", vbCritical,
"Critical Error"
Exit Sub
End If
' The first child window is of class ODsk
hWndODsk = FindWindowEx(hW ndRel, 0&, "ODsk", vbNullString)
' Loop through all of this level's Windows.
' We are looking for any windows with a negative
' Left value in it's Window Rectangle
' Let's get first Child Window of the ODsk window
hWndTemp = apiGetWindow(hW ndODsk, GW_CHILD)
If hWndTemp = 0 Then
MsgBox "Their are no Relationships!" , vbCritical, "Critical Error"
Exit Sub
Else
lngRet = GetWindowRect(h WndTemp, rc)
If rc.Left < 1 Then
rc.Left = 1
lngRet = SetWindowPos(hW ndTemp, 0&, rc.Left, rc.Top, 0&, 0&,
SWP_NOSIZE)
End If
End If
' Let's walk through every sibling window
Do
' Let's get the NEXT SIBLING Window
hWndTemp = apiGetWindow(hW ndTemp, GW_HWNDNEXT)
If hWndTemp <0 Then
lngRet = GetWindowRect(h WndTemp, rc)
If rc.Left < 1 Then
rc.Left = 1
lngRet = SetWindowPos(hW ndTemp, 0&, rc.Left, rc.Top, 0&,
0&, SWP_NOSIZE)
End If
End If
' Let's Start the process from the Top again.
' End this loop if no more Windows.
Loop While hWndTemp <0
' All done
Exit_cmdFix_Cli ck:
Exit Sub
Err_cmdFix_Clic k:
MsgBox Err.Description
Resume Exit_cmdFix_Cli ck
End Sub
--
HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.