Position Msgbox (1 Viewer)

A17BPG

New member
Local time
Today, 05:22
Joined
Mar 30, 2018
Messages
23
Hi

Does anyone know if you can place a msgbox anywhere on a Form other than in the centre. ie placing say on the right or in a top corner.

Thanks in anticipation Brian.
 

Dreamweaver

Well-known member
Local time
Today, 12:22
Joined
Nov 28, 2005
Messages
2,466
Dont think so but you could use a form made to look like a message box then move it where you wanted I know isladog posted code for moving a form.

Hope it helps mick
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 07:22
Joined
Feb 28, 2001
Messages
27,001
The only way to do that is if the message box is NOT modal (which means that other code can run behind it) but it also requires you to find ALL windows (including child windows) to find which one is the message box. If you could run code AND if you could find the child box, you would be able to manipulate is positional properties.

However, that is not something that is easy to do. The whole point of a message box is that it is up front and dead center in order to get your attention and MAKE you do something, choose something. To do otherwise is to defeat its purpose.

I think MickJay's suggestion is better... if the purpose isn't to force someone to decide something, then maybe it shouldn't be a message box.
 

Micron

AWF VIP
Local time
Today, 08:22
Joined
Oct 20, 2018
Messages
3,476
I can envision a situation where the message box might cover some vital information that pertains to the message, and if you can't see that information, it may be problematic in dealing with the message. Don't forget that the message box may not be one that results in a simple OK response - it could contain 3 options and the info may need to be seen in order to facilitate a choice.

If that is the case, I'd go with a form as suggested, but make it modal. Seems obvious to me that if a decision needs to be made, there ought not to be any further code execution until the choice is made, so modal ought to function well in a case like this.
EDIT - forgot to say that the MoveSize method used in form opening may be simple enough for positioning such a form.
 

isladogs

MVP / VIP
Local time
Today, 12:22
Joined
Jan 14, 2017
Messages
18,186
As previously mentioned, you can make your own message form and place it where you like. See the customised message box in my example Attention Seeking app.
I would also make it popup and modal so the user has to respond in order to proceed.
The code to place it where you want has the syntax
Code:
DoCmd.MoveSize Left, top, width, height
with all arguments optional. Values are in twips with 1440 twips = 1 inch (567 tips = 1 cm)

If you want to place the form precisely in relation to another object, see this article on my website Accurately Move Forms and Controls
 
Last edited:

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 07:22
Joined
Feb 28, 2001
Messages
27,001
Let's not forget that you CAN manually drag a modal message box to the side to see things if it is covering up something. You just can't do anything underneath it.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:22
Joined
May 7, 2009
Messages
19,175
I submitted the same (code repository) for the mods approval.
 

Attachments

  • messageBox.zip
    134.6 KB · Views: 169

Users who are viewing this thread

Top Bottom