Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Position Message boxes

Status
Not open for further replies.

kaiana

Programmer
Joined
Sep 6, 2002
Messages
85
Location
AU
I have a database that I am programatically positioning forms in certain areas of the screen. However, when a message box comes up it comes up in the middle of the screen I want it to come up in the middle of the form that it actually relates to.
 
You can use a form instead of a message box. Set it's border style to dialogue, Control Box to no, Record Selectors to no, Navigation Buttons to no, Dividing Lines to no and Auto Center to no. Now drop a Close button and a label (with your message) on it and you have a positionable 'message box'. "The Key, The Whole Key, and Nothing But The Key, So Help Me Codd!"
 
Thanks, I never thought about doing it that way. When I have quite a few message boxes to do this with, will it slow things down using forms instead of message boxes?

 
A form with only a label and one or two buttons will load very quickly.

I would suggest you use one generic form and set the message and button label properties when you open it, rather than having separate forms for every possible message.

Or you could have the basic buttons and make them visible/invisible as needed. "The Key, The Whole Key, and Nothing But The Key, So Help Me Codd!"
 
Thanks 930 Driver I will give that a go. I was thinking I would have to do one for every scenario.
 
Also, you'll want to look up help on DoCmd.MoveSize to position the form where you want it. "The Key, The Whole Key, and Nothing But The Key, So Help Me Codd!"
 
You could also define a couple of "Public" variables in the form to hold captions for a pair of Yes/No buttons. Then when the form loads do

Public FormName As Form
Public YesCaption As String
Public NoCaption As String
Public Reply As Boolean

btnYes.Caption = YesCaption
btnNo.Caption = NoCaption
If Iif(IsNull(NoCaption),"",NoCaption) = "" Then
btnNo.Visible = False
End If
Use the .Height & .Width properties of the calling form to decide where to position the generic form.

You could use the btnYes_Click event to set Reply = True and do some fancy stuff to centre the buttons on the new generic form depending on whether the NoCaption field has been populated. I think you could then do

Dim frm As New WhateverYourFormNameIs
Set frm.FormName = Me
frm.YesCaption = "Okay"
frm.NoCaption = "Cancel"

When you open it as Modal, you can then refer to the frm.Reply variable to decide whether they have cancelled or not.

Is this of any use, or have I just built the Eiffel Tower when the spec was for a garden shed?
 
PeteJohnston

Don't know yet, still climbing. Interesting perspective. That's what I love about this site, you put on a question expecting it to go a certain way and then have to do a 180 as it is nothing like I was expecting.

thanks for the notes, will go over them

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top