470,590 Members | 2,039 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,590 developers. It's quick & easy.

Releationship diagram goes haywire

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?

Aug 27 '06 #1
3 4567
On 27 Aug 2006 11:16:49 -0700, "Terry" <te*********@oel.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?
Aug 28 '06 #2
"Tom van Stiphout" <no*************@cox.netwrote in message
news:lb********************************@4ax.com...
On 27 Aug 2006 11:16:49 -0700, "Terry" <te*********@oel.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 programmatically 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 _
"FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias _
"FindWindowExA" (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 "GetClassNameA" _
(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 _
"PostMessageA" (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_cmdCloseWindow_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(vbNullString, "Debug Window")
If hWndDebug <0 Then
lngRet = PostMessage(hWndDebug, WM_CLOSE, 0&, 0&)
Exit Sub
End If
' The Debug Window is a child of the MDI window
' find MDIClient first
hWndMDI = FindWindowEx(Application.hWndAccessApp, 0&, "MDIClient",
vbNullString)
' Find the Debug Window
hWndDebug = FindWindowEx(hWndMDI, 0&, "OImmediate", "Debug Window")
If hWndDebug <0 Then
lngRet = PostMessage(hWndDebug, WM_CLOSE, 0&, 0&)
Else
MsgBox "The Debug Window is not open."
End If
Exit_cmdCloseWindow_Click:
Exit Sub
Err_cmdCloseWindow_Click:
MsgBox Err.Description
Resume Exit_cmdCloseWindow_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_Click
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.RunCommand acCmdRelationships
' The window must be maximized
DoCmd.Maximize
DoEvents
' The Relationships Window is a child of the MDI Client window
' find MDIClient first.
hWndMDI = FindWindowEx(Application.hWndAccessApp, 0&, "MDIClient",
vbNullString)
' Find the Relationships Window
hWndRel = FindWindowEx(hWndMDI, 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(hWndRel, 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(hWndODsk, GW_CHILD)
If hWndTemp = 0 Then
MsgBox "Their are no Relationships!", vbCritical, "Critical Error"
Exit Sub
Else
lngRet = GetWindowRect(hWndTemp, rc)
If rc.Left < 1 Then
rc.Left = 1
lngRet = SetWindowPos(hWndTemp, 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(hWndTemp, GW_HWNDNEXT)
If hWndTemp <0 Then
lngRet = GetWindowRect(hWndTemp, rc)
If rc.Left < 1 Then
rc.Left = 1
lngRet = SetWindowPos(hWndTemp, 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_Click:
Exit Sub
Err_cmdFix_Click:
MsgBox Err.Description
Resume Exit_cmdFix_Click
End Sub

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.

Aug 28 '06 #3
That worked!
Brilliant!
Many thanks Stephen

Terry

Aug 29 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Maria | last post: by
2 posts views Thread by Mihir | last post: by
4 posts views Thread by PIEBALD | last post: by
70 posts views Thread by Anson.Stuggart | last post: by
1 post views Thread by Jennifer Jazz | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.