vb6 what is a forms owner ?

Posted on 2013-12-18
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 ?
Question by:isnoend2001
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
LVL 48

Expert Comment

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

Public gstrOpenedBy As String

Open in new window

Form1 code:
gstrOpenedBy = Name

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

LVL 48

Accepted Solution

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
End Sub

Open in new window


Author Closing Comment

ID: 39728097
thanks now i know
LVL 48

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month7 days, 19 hours left to enroll

617 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