Solved

vb6 what is a forms owner ?

Posted on 2013-12-18
4
289 Views
Last Modified: 2013-12-18
I am trying to write some code in a forms queryunload.
is the form that opened it the forms owner or can i specify the owner ?
0
Comment
Question by:isnoend2001
  • 3
4 Comments
 
LVL 45

Expert Comment

by:Martin Liss
ID: 39728064
Module code:
Option Explicit

Public gstrOpenedBy As String

Open in new window


Form1 code:
gstrOpenedBy = Name
Form2.Show

Open in new window


Form2 code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
MsgBox "The form that opened me is " & gstrOpenedBy

End Sub

Open in new window

0
 
LVL 45

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 39728085
Oh, and if you waht to do something with the form that did the opening you can do the following:

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

Dim frm As Form
MsgBox "The form that opened me is " & gstrOpenedBy

For Each frm In Forms
    If frm.Name = gstrOpenedBy Then
        frm.BackColor = vbRed
        Exit For
    End If
Next
End Sub

Open in new window

0
 

Author Closing Comment

by:isnoend2001
ID: 39728097
thanks now i know
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 39728105
You're welcome and I'm glad I was able to help.

Select the 'About Me' tab in my profile and you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2013
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

758 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

17 Experts available now in Live!

Get 1:1 Help Now