Solved popup & modal (2 Viewers)

John Sh

Active member
Local time
Today, 15:41
Joined
Feb 8, 2021
Messages
626
The small form pictured below, requires an input before the program can continue.
If I set it as popup and modal it does not stop the program unless I also set "acdialog" in the docmd.openform statement.
Acdialog puts the form on top and stops the program regardless of the popup and modal settings.
I am using Access 2016 and Windows 10

1) am I missing a setting somewhere, and
2) how go I get rid of the form label and green bar?

Screenshot_2.jpg
 
All my forms borders are set to none.
This label and bar only appears on forms that are set to acdialog.
Screenshot_3.jpg
 
2. Set the border style to Dialog.
Open it as acDialog , set control box to no, close button to no. Remove the caption.
 
you can Remove the Label/Box from your form.
or you can Set their Visible Property to No.

you can pass an OpenArgs parameter when opening a Form as acDialog:

Code:
DoCmd.OpenForm FormName:="YourFormName", WindowMode:=acDialog, OpenArgs:="Dialog"

then on the Open event of YourFormName, you check if "Dialog" is passed as parameter:

Code:
Private Form_Open(Cancel As Integer)
If Me.OpenArgs & "" = "Dialog" Then
    Msgbox "Form is opened in Dialog mode"
Else
    Msgbox "Form is not opened in Dialog mode"
End If
End Sub

There is also an API to check if it is opened as acDialog, but unfortunately it draws back those borders.
 
Last edited:
2. Set the border style to Dialog.
Open it as acDialog , set control box to no, close button to no. Remove the caption.
If you look at the second screen shot you will see control box is no, close button is no and there is no caption!
Not much left to do there.
 
you can Remove the Label/Box from your form.
or you can Set their Visible Property to No.

you can pass an OpenArgs parameter when opening a Form as acDialog:

Code:
DoCmd.OpenForm FormName:="YourFormName", WindowMode:=acDialog, OpenArgs:="Dialog"

then on the Open event of YourFormName, you check if "Dialog" is passed as parameter:

Code:
Private Form_Open(Cancel As Integer)
If Me.OpenArgs & "" = "Dialog" Then
    Msgbox "Form is opened in Dialog mode"
Else
    Msgbox "Form is not opened in Dialog mode"
End If
End Sub

There is also an API to check if it is opened as acDialog, but unfortunately it draws back those borders.
Sorry Arnelgp, you've lost me.
If I open with acdialog, why would I need to check what I already know, and how does that make a difference to the form?
This is the function that opens the form.
"bYN" is a global boolean variable.

Code:
Public Function Messenger() As Boolean
    DoCmd.OpenForm "messenger", , , , , acDialog
    Messenger = bYN
End Function
 
If you look at the second screen shot you will see control box is no, close button is no and there is no caption!
Not much left to do there.
yes I have seen the screen shot.
the problem is when you open the form (DoCmd.OpenForm) and you specify acDialog, the Titlebar
will get re-instated.

try opening your form normally:
Code:
DoCmd.OpenForm FormName:="YourFormName"
you will notice that there is No Titlebar.
Now open it using acDialog:
Code:
DoCmd.OpenForm FormName:="YourFormName", WindowMode:=acDialog
immediately the Titlebar will appear.
 
Maybe I should clarify.
I am not talking about a textbox or combobox label. There are none on the form and they are easily controlled with code or in properties.
I am talking about the "label", "caption" on the form that say's "Messenger" and the green bar on top of the form. That is what I want to get rid of.
I have tried all four border settings to no avail.
If I set the form to popup on and modal on without acdialog it does not stop the program flow.
I want a form that looks like this. No Caption and no green bar
Screenshot_4.jpg
 
yes I have seen the screen shot.
the problem is when you open the form (DoCmd.OpenForm) and you specify acDialog, the Titlebar
will get re-instated.

try opening your form normally:
Code:
DoCmd.OpenForm FormName:="YourFormName"
you will notice that there is No Titlebar.
Now open it using acDialog:
Code:
DoCmd.OpenForm FormName:="YourFormName", WindowMode:=acDialog
immediately the Titlebar will appear.
If I don't specify acdialog then the form does not stop program flow, it just sits behind the next form that opens.
 
As you can see, the form requires the "Yes" or "No" button to be clicked to direct program flow.
Without acdialog and with popup and modal on, this does not happen.
 
see this demo and open MainForm.
this will make Form1 (dialog or not).
see the code of the two buttons.
there is a basMakeFormDialog, that does the Modal thing.
 

Attachments

Screenshot_5.jpg

Contrary to what this say's, setting the form's "Modal" property to on is having no effect on the form's behaviour
Screenshot_6.jpg
 
see this demo and open MainForm.
this will make Form1 (dialog or not).
see the code of the two buttons.
there is a basMakeFormDialog, that does the Modal thing.
Thank you. It's bedtime, I'll have a look in the morning.
John
 
unfortunately the demo did not work when i tested it.
i modified the code (VBA) in "Open Form1 (Modal)" button
to somewhat make it stop.
 

Attachments

You must set the form border style to dialog, not NONE.
Unless you use code as I assume @arnelgp has done, a form opened using acDialog will always have a title bar even if you remove the form caption and control box . . . no matter what the border style is specified as.

1756988812377.png


Is your message form a 'special type' of form?
In the screenshot shown in post #1, the title bar that you don't want has a green background. How have you achieved that?
 
Is your message form a 'special type' of form?
In the screenshot shown in post #1, the title bar that you don't want has a green background. How have you achieved that?
I didn't "achieve" that, it's just the way it is.
 
Is your message form a 'special type' of form?
In the screenshot shown in post #1, the title bar that you don't want has a green background. How have you achieved that?
I didn't fully answer you.
The form is a standard single form, albeit resizable in width depending in the length of the strings.
 
John, I think Colin is wondering why the title bar is a dark green. My popup form shows a very light green.
 

Users who are viewing this thread

Back
Top Bottom