Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

vb6 what is a forms owner ?

Posted on 2013-12-18
4
Medium Priority
?
342 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 49

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 49

Accepted Solution

by:
Martin Liss earned 2000 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 49

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…
Suggested Courses

877 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