Control the order of tabbed documents?

XV1957

Registered User.
Local time
Today, 09:03
Joined
Aug 6, 2014
Messages
80
Hello experts,
I prefer working with tabbed documents in my DB.
Every new form opened, opens to the right of the previous one.
Is there a way to control that behaviour, and for instance open a certain form between two forms (between two tabs)?
 
Are you saying that if you switch from Tab "A" to Tab "B" that you want to pop up a separate form that is not part of the tabbed panels on your main form?

If so, look at the Tab OnClick event or the OnChange event.

If that is NOT what you meant, please clarify your request.
 
Are you saying that if you switch from Tab "A" to Tab "B" that you want to pop up a separate form that is not part of the tabbed panels on your main form?

If so, look at the Tab OnClick event or the OnChange event.

If that is NOT what you meant, please clarify your request.
I think the OP is talking about the tabbed forms - as opposed to Windowed forms i.e. when a new form is opened, it is opened as a new tab. I might be wrong :confused:

If so then its a reasonable question. However, I can't seem to be able to change the tab order manually - like you would in say Chrome browser.
 
Hi Guys, yes I was thinking of tabbed Forms as opposed to windowed Forms.
An example will clarify. Say I open a Company form first, and then some others that bear no special relationship to that company form. Now, from my company form, I open an employee form. The company form is on the left of my screen, whilst the employee form is at the extreme right side of my screen.
I would love to be able to open the employee form right next to the company form for example.
 
In overview, you would have to have a common element between the two forms to control them both. What you need to do is to identify the "window handle" (usually in MS Windows, call hWnd) and pass it, along with other information, to a window manipulator.

I don't remember the article where I found this, but you would be able to do window movement or placement with some subroutine and function calls from the User32.DLL file, which should be documented in MSDN.

Look for (search the web for) WM_apiSetWindowPos, WM_apiGetDeskTopWindows, WM_apiGetWindowPlacement, and a few other useful entry points in User32 for the things you need to do to diddle window position, including child windows.

It is a bit complex for me to explain and the MSDN articles (plus some other articles from the various forums) were helpful. In this case, I'm a bit too busy to explain much more than that you create a couple of data structures, call these routines to get info about the current windows in question, and can then see or modify positional information in the structures and make another call to implement any changes required.

The reason I said you need something in common between them is that if they are opened independently, they might have trouble finding each other. But if you had some sort of common "switchboard" form that "knows" what is open, it could simply force related forms to move side-by-side FROM THE SWITCHBOARD, not from the opened child windows. I.e. the controlling form is the closest program entity that knows where both forms are located.
 
Worth investigating but I'm not sure tabbed forms can be identified with hwnd since they take up space within the access window so are not actually a window in their own right

I've had a google around for ideas but without success.

I've solve the problem myself in a slightly different way - although not for the OP's reasons, more to create something really flexible

Other than a few modal forms for my 'standard design' I have just one main form with a number of unbound subform controls. As users select an option, rather than opening as a new form, the form is assigned as source object to one of the subforms. With code you can resize the subforms and move them around as required - so could move the employee subform next to the customer subform for example to view side by side. For the OP, rather than subforms, perhaps use an alternative control such as textbox, button or image which when clicked opens the relevant subform.
 
Thank you both for pointing directions.
There seems to be enough material there to keep me busy for a while.
CJ_Londen, if you could point to an example of what you describe in your last paragraph, that would be fantastic.
Appreciate the help!
 
no example that I am aware of and I regret I don't have time to create one

you just use the .move method of resizing and repositioning controls - and/or the control visible property if required. So typically 5 properties to play with - left, top, height, width and visible.

Only other thing is referencing one form from another is slightly different since they are all subforms.

And consider the form resize event for moving controls around to fit different sized screens.

if you have a table to store user selections and/or preferences you can have it open to the last view the user had or prefers when they login.

I typically have a navigation form to the left or top, notifications to the right, 'action' buttons to the bottom (print/save etc) and the use the centre space for everything else
 
got this bit of code which might interest you - enables a user to move a control up and down using the mouse events - change Ctrl to name of the control you want to move

Code:
Option Compare Database
Option Explicit

Dim mseDown As Boolean
Dim startY As Single

Private Sub Ctrl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
    mseDown = True
    startY = Y
 
End Sub

Private Sub Ctrl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next

    If mseDown And (Ctrl.Top + Y - startY) > 0 Then Ctrl.Top = Ctrl.Top + Y - startY

End Sub

Private Sub Ctrl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
 
    mseDown = False
 
End Sub
 
Hi CJ_London,
thank you very much for pointing the way.
I will start right away with these concepts.
 

Users who are viewing this thread

Back
Top Bottom