Solved

vb6 what is a forms owner ?

Posted on 2013-12-18
4
303 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 46

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 46

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 46

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel object stays open 19 76
Using "ScreenUpdating" 6 66
Question about INSTR  - need to extract data MS ACCESS query 6 56
How does CurrentUser work? 10 37
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

831 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