How to check if a window is modal/popup (1 Viewer)

AndrewS

Registered User.
Local time
Today, 09:55
Joined
Feb 21, 2017
Messages
30
Here's the situation:

User can type into a Enter Company Name combobox. If there's a match, the match is displayed. If there isn't a match, a NotInList event asks them if they want to add a new company.
So far, so good.

If they say yes, frm_companies opens using DoCmd.OpenForm "frm_companies", , , , acFromAdd, acDialog.

I also use frm_companies for data entry and viewing, and as it has subforms and sub-subforms, I'm trying to not have to recreate it. But if it's opened modally like this, I'd like to hide certain controls that really only apply to viewing and editing.

Is there a way to test if the form is open modally, so I can set those controls' .visible to false?

I tried searching the web, and one found one case where someone was trying to do something similar. So I suspect the answer is no, or at least not easily, and that the easiest solution is just to create a new form, but I thought I'd see if anyone had ideas.

Thanks
 

isladogs

MVP / VIP
Local time
Today, 09:55
Joined
Jan 14, 2017
Messages
18,239
Is there a way to test if the form is open modally, so I can set those controls' .visible to false?

Yes & its unbelievably obvious too...
Add this code to Form_Load event

Code:
If Modal Then
   'add code to hide selected controls here
Else
  'if needed, add code to show selected controls here
End If
 

AndrewS

Registered User.
Local time
Today, 09:55
Joined
Feb 21, 2017
Messages
30
Excellent. Many thanks to you both.

The openargs idea had occurred to me in another context, but I'd not followed it through, so that will be very useful too.
 

AndrewS

Registered User.
Local time
Today, 09:55
Joined
Feb 21, 2017
Messages
30
Update:

The acDialog seems not to set the forms .modal or .popup properties.

Having opened the form using acDialog, me.modal and me.popup still evaluate as False.

OpenArgs seems the easiest way to accomplish what I want.

Thanks again.
 

isladogs

MVP / VIP
Local time
Today, 09:55
Joined
Jan 14, 2017
Messages
18,239
Update:

The acDialog seems not to set the forms .modal or .popup properties.

Having opened the form using acDialog, me.modal and me.popup still evaluate as False.

OpenArgs seems the easiest way to accomplish what I want.

Thanks again.

Opening a form using acDialog overwrites any other form conditions.
You shouldn't have used that 'mode' if you wanted to test if a form was modal or indeed if it was a popup form
 

RuralGuy

AWF VIP
Local time
Today, 02:55
Joined
Jul 2, 2005
Messages
13,826
Opening a form using acDialog overwrites any other form conditions.
You shouldn't have used that 'mode' if you wanted to test if a form was modal or indeed if it was a popup form
I'm sorry Colin, but I think you were a little harsh with your comment. I believe your opinion only applies to *your* solution but not to all solutions. It just struck me as very unlike your usual assistance.
 

isladogs

MVP / VIP
Local time
Today, 09:55
Joined
Jan 14, 2017
Messages
18,239
I'm sorry Colin, but I think you were a little harsh with your comment. I believe your opinion only applies to *your* solution but not to all solutions. It just struck me as very unlike your usual assistance.

Hi Allan

Sorry if that's how it came across to you or anyone else
It wasn't intended to be critical in any way.

My point was just that
opening a form using acDialog overwrites any other form conditions.
 

RuralGuy

AWF VIP
Local time
Today, 02:55
Joined
Jul 2, 2005
Messages
13,826
Certainly a valid point but you have to admit that my solution did not suffer from that drawback. Your very helpful post are always filled with useful tips and I admire them a lot.
 

isladogs

MVP / VIP
Local time
Today, 09:55
Joined
Jan 14, 2017
Messages
18,239
Thanks for compliment which I reciprocate
And of course you are right that using Open Args was a perfectly valid solution.

My comment was purely a response to the original question by the OP when he wrote:
Is there a way to test if the form is open modally
 

RuralGuy

AWF VIP
Local time
Today, 02:55
Joined
Jul 2, 2005
Messages
13,826
That is indeed a useful discussion for this thread Jack. Thank you for posting. BTW, were you aware of the fact that Albert was NOT renewed as an MVP this month? I couldn't believe it.
 

isladogs

MVP / VIP
Local time
Today, 09:55
Joined
Jan 14, 2017
Messages
18,239
@jdraw
Thanks Jack - it made interesting reading

@ruralguy
Any idea how such decisions are made?
Albert is a mine of useful information
 

RuralGuy

AWF VIP
Local time
Today, 02:55
Joined
Jul 2, 2005
Messages
13,826
I'm a member of an MVP forum that now has a lot of ex-MVP's. None of us can figure out how MS makes its decisions here. Albert is going to try and reapply in a few months.
 

jdraw

Super Moderator
Staff member
Local time
Today, 04:55
Joined
Jan 23, 2006
Messages
15,379
Hi Allan,

No I wasn't aware. But there are a few that were not renewed that raised some concerns on different forums and the mvp-non disclosure. I am on Access mvp. What is the group you mentioned?
 

isladogs

MVP / VIP
Local time
Today, 09:55
Joined
Jan 14, 2017
Messages
18,239
Allan / Jack

Does that mean ex-MVPs (such as yourself, Allan) are no longer subject to the non-disclosure agreement?
 

RuralGuy

AWF VIP
Local time
Today, 02:55
Joined
Jul 2, 2005
Messages
13,826
Frankly, I for one still abide by my NDA. I suspect so do the others. We can no longer participate in NDA discussions though.
 

RuralGuy

AWF VIP
Local time
Today, 02:55
Joined
Jul 2, 2005
Messages
13,826
@Colin - Now that I think about it, I believe all of the information that would be covered by an NDA becomes public in a short amount of time; usually months.
 

Users who are viewing this thread

Top Bottom