Solved

Open a form "modally" with respect to only one other form

Posted on 2000-03-30
13
170 Views
Last Modified: 2010-05-02
Is there any way to show a form modally, but only lock one of the program's forms?

For example, form3 is shown, and form2 can't be accessed until form3's been closed, but form1, form4, etc. can still be used?

Thanks.
0
Comment
Question by:aerelorn
  • 5
  • 5
  • 3
13 Comments
 
LVL 28

Expert Comment

by:AzraSound
ID: 2670395
might try just setting form2.enabled = false on form3 load and set it back to true when you close form3
0
 

Author Comment

by:aerelorn
ID: 2670543
The only problem I can see with that is I'd like it to show form3 if you switch to form2 by clicking in the taskbar or somesuch.
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2670599
i'm sorry can you explain what you mean exactly
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2670656
perhaps you can just hide the form instead of disabling it??
0
 

Author Comment

by:aerelorn
ID: 2670688
Suppose you switch to another application, and then click on form2 in the taskbar.  It'll show itself, but its disabled, and there's no indication to the user that they need to fill out form3 first.  
I'd like it so if you come back to form2, it'll show form3.  Like when you show a form modally, and you switch back to any form in the application, it'll show the modal form.
0
 
LVL 4

Expert Comment

by:gcs001
ID: 2670708
You can try something like this in Form2's Activate event ...

Private Sub Form_Activate()
    Dim tmpForm As Form
   
    For Each tmpForm In Forms
        If tmpForm Is Form3 Then
            Form3.Show
        End If
    Next tmpForm
End Sub


This will basically check if Form3 is loaded before Form2 is shown - if it is loaded then Form3 will be displayed.
This will also work if you select Form2 from your taskbar with Form3 still open.

Hope this helps.

Regards,
Grant.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:aerelorn
ID: 2670744
That would work beautifully gsc001, but the Form_Activate event doesn't go off if the form is currently disabled.
0
 
LVL 28

Accepted Solution

by:
AzraSound earned 100 total points
ID: 2670778
Why dont you just hide the form??  That makes it pretty clear you cant do anything with it and it makes it impossible for the user to do anything to the form

But I modified the above code to do it too:

Private Sub Form_Activate()
    Dim tmpForm As Form
    For Each tmpForm In Forms
        If tmpForm Is Form3 Then
            Form3.Show
            Form2.Enabled = False
        End If
    Next tmpForm
    Form2.Enabled = True
End Sub
0
 
LVL 4

Expert Comment

by:gcs001
ID: 2670807
Instead of Form2.Enabled = False, use Form2.Hide!
0
 

Author Comment

by:aerelorn
ID: 2670942
I don't want to hide the form.
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2671133
did you try my modified code?
0
 
LVL 4

Expert Comment

by:gcs001
ID: 2671140
Why do you want to disable the form?
It wouldn't be necessary as the code would not set the focus to Form2 unless Form3 is closed!
0
 

Author Comment

by:aerelorn
ID: 2671209
Ok, thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
LINQ return type for nested group query 6 71
vb6 programatically bring window to front 8 63
VBA error replacing data 6 37
Copy a row 12 58
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now