Solved popup & modal (2 Viewers)

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.
I think I'm stuck with the form the way it is.
I might have to write a loop around the buttons, or the form, that goes nowhere until a button is clicked.
I have implemented Arnelgp"s code, with the module and without.
The form is accepting "modal on" but is still not stopping program flow.

Can there be some peculiar behaviour in the "Forms.Modal" property, which should stop program flow.
I have been through all the options and cannot see anything that might change this behaviour.

Code:
  Private Sub Form_Open(Cancel As Integer)
    If Me.OpenArgs & "" = "dialog" Then MakeFormDialog Forms("Messenger")
End Sub

Also the title bar is still visible but is now white.

Screenshot_7.jpg
 
i updated the Attached db and is now Not using any API. pls download it again.
 
As a matter of interest, I've just created a blank form and set modal on is blocking program flow.
I will rebuild the form and see what happens.
I will also try Arnelgp"new code.
I offer my thanks and gratitude to all.
Watch this space.
John
 
I've just created a blank form and set modal on is blocking program flow.
That surprises me. I'll have to try it out. Or, if you could post a sample db, that would be great.
 
A simple work around.
The form is now popup on modal off and opened with
Code:
Public Function Messenger() As Boolean
    DoCmd.OpenForm "messenger"
    Messenger = bYN
End Function

I have modified the form's code to become

Code:
Option Compare Database
Option Explicit
Private bOut As Boolean

Private Sub btnNo_Click()
    bOut = True
End Sub

Private Sub btnOK_Click()
    bOut = True
End Sub

Private Sub btnYes_Click()
    bOut = True
    bYN = True
End Sub

Private Sub CloseMe()
    Do
        DoEvents
    Loop While Not bOut
End Sub

Private Sub Form_Load()
    bYN = False
    getWidth
    Me.btnMessage.Caption = strMessage
    Me.btnOK.Visible = IIf(bOK = True, True, False)
    Me.btnNo.Visible = IIf(bOK = False, True, False)
    Me.btnYes.Visible = IIf(bOK = False, True, False)
    Me.imgCritical.Visible = IIf(strImage = "C", True, False)
    Me.imgInformation.Visible = IIf(strImage = "I", True, False)
    Me.imgExclamation.Visible = IIf(strImage = "E", True, False)
    If strImage = "C" Then
        Me.btnMessage.ForeColor = RGB(0, 0, 0)
        Me.btnMessage.BackColor = RGB(255, 253, 25)
        Me.btnMessage.HoverColor = RGB(255, 253, 25)
        Me.btnMessage.HoverForeColor = RGB(0, 0, 0)
    ElseIf strImage = "E" Then
        Me.btnMessage.ForeColor = RGB(255, 255, 0)
        Me.btnMessage.BackColor = RGB(253, 0, 0)
        Me.btnMessage.HoverColor = RGB(255, 0, 0)
        Me.btnMessage.HoverForeColor = RGB(255, 255, 0)
    End If
    Me.Visible = True
    CloseMe
    DoCmd.Close acForm, Me.Name
End Sub

Previously the btn onclick events were closing the form

The sub "CloseMe" simply loops until a button is clicked. bOut reverts to true and the loop ends.
An essentially modal form without being modal.
QeD.

Screenshot_8.jpg

Once again, many thanks to all.
John
 

Users who are viewing this thread

Back
Top Bottom