Solved

vb6 what is a forms owner ?

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

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
consolidate or create a new vba code for performing tasks 5 63
Problem to skip loop 6 54
VB error "Type mismatch" 2 49
How to Add / Edit Windows Menu 4 50
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…

919 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

13 Experts available now in Live!

Get 1:1 Help Now