Modal Pop-up can't be set Visible (1 Viewer)

GK in the UK

Registered User.
Local time
Today, 20:16
Joined
Dec 20, 2017
Messages
274
Here's the issue: A form (#1) opened acDialog, can open another form (#2), Modal Pop-up with WindowMode:=acHidden but not acDialog and then set itself (form #2) Visible = true after stuff is passed in.

When form #2 is done it sets itself me.visible=false and form#1 gets the return values. As long as form #1 remains open, remember it was opened first, form #2 can be hidden and shown as many times as necessary.

So when form #1 is closed, form #2 remains loaded but hidden.
When form #1 is re-opened, form #2 seemingly can never be made visible again. There is no complaint, and the Let Property sub in form #2 runs, the final line is Me.Visible=true, but it doesn't happen. Here's the last bit of code in the Property Let sub of form #2:

Code:
Me.Visible = True
 
 Debug.Print "2.SrchFrm.Visible " & Me.Visible            ' < FALSE !
 Debug.Print "2.SrchFrm.Modal   " & Me.Modal            ' True
 Debug.Print "2.SrchFrm.PopUp   " & Me.PopUp            ' True
 
MsgBox "3.Public Property Let SrchTxt:  Me.Visible = " & Me.Visible   ' < FALSE !

So it seems that Me.visible=true is ignored, if that form (#2) was already open, but hidden, when the acDialog form called it.

So I somehow need to replicate the conditions that existed, when both forms were open, and the Property Let statement in form#2 could set itself visible.

Done the usual de/recompile and compact & repair.
 

Ranman256

Well-known member
Local time
Today, 15:16
Joined
Apr 9, 2015
Messages
4,337
if the modal form is open , you cannot set any property from outside the form. (hello...modal)
you can set stuff inside the modal form events.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 15:16
Joined
May 21, 2018
Messages
8,527
I tested this and can replicate that behavior, but no idea why that is. Can you simply call to close the form and reopen. This will show it and will not error if the form is not open.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 15:16
Joined
May 21, 2018
Messages
8,527
The above may not be suitable if form2 has code when it opens
 

GK in the UK

Registered User.
Local time
Today, 20:16
Joined
Dec 20, 2017
Messages
274
Ranman256, I think you've got me on the road to recovery. Actually I was setting stuff in the Modal form, as long as the acDialog form was opened first. So maybe it only had the right 'Modal' priority then. But once it was already open and hidden, re-opening the acDialog form maybe then took priority ... oh I don't know.

Anyway, and this looks promising, and for the benefit of anyone else reading this: As soon as my acDialog form wants to open Form#2, it 'gives up' Modal status. Form #2 sets itself Me.Visible=true, which now works, and then sets itself Modal=true so we can't go anywhere else. Here's my code to manage the Modal form opened from an acDialog form. This has been about two goals really: enabling the Modal form to be resized in use, and to keep it loaded as it's used so regularly. It's so much snappier when it opens from hidden. Closing the form was my 'get out', it all worked but that's not what I wanted. I'll give this a thorough test out but it seems to work. Thank you.

Code:
Private Sub OpenSrchForm(strQry As String, strFind As String)
  Me.Modal = False                                      ' give up Modal status, frm_Srch is going to claim that status
  DoCmd.OpenForm gstrSearch, WindowMode:=acHidden
  ' Pop-up & Modal form can be resized, this sub concludes but then
  ' we must wait for the custom events to fire on the search form
  Set SrchFrm = Forms(gstrSearch)
  SrchFrm.SrchQry = strQry
  SrchFrm.SrchTxt = strFind                             ' Let Property sub claims Modal status for frm_Srch
End Sub


Private Sub SrchFrm_CancelSrch()                        ' CUSTOM EVENT raised by frm_srch
  Me.txtNominalFK = Me.tlNominalFK                      ' revert unbound field to bound value
  Me.Modal = True                                       ' revert this form to Modal so we can't go anywhere else
End Sub


Private Sub SrchFrm_GotSrchResult()                     ' CUSTOM EVENT raised by frm_srch
  ' this form (frm_PaymentLine) has been stuck in limbo
  ' as the search form was opened Pop-up and Modal, get
  ' the values from the form when we get the custom event
  AssignNominal Nz(SrchFrm.txtPK)
  Me.Modal = True                                       ' revert this form to Modal so we can't go anywhere else
End Sub
 

Users who are viewing this thread

Top Bottom