If I have a form which can be called from other forms, how can I determine the name of the calling form? My attempt to use Application.CurrentObject does not seem to work, and I cannot find anything similar to Recordset.State to determine a form’s status (open or closed)
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Determining the state of a form (XP)
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Determining the state of a form (XP)
- This topic has 9 replies, 5 voices, and was last updated 22 years, 6 months ago.
Viewing 1 reply threadAuthorReplies-
WSSupport4John
AskWoody LoungerDecember 17, 2002 at 7:15 pm #639365Hi Steve
You can use a global variable for this purpose. You will have to use a “wrapper” function to retrieve global variable’s value. You would set value when report is opened from form. Example: In standard code module create Public variable and function:
Option Compare Database
Option ExplicitPublic gstrFormName As String
Public Function GetFormName() As String
GetFormName = gstrFormName
End FunctionWhen opening report use code like this:
Private Sub OpenRpt_btn_Click()
Dim strRpt As String
gstrFormName = Me.Name
strRpt = “rptEmployees”
DoCmd.OpenReport strRpt, acPreviewEnd Sub
To get name of form in report, call GetFormName function. To test this, add unbound textbox to report with following expression as ControlSource:
=”Form Opened by: ” & GetFormName()
The textbox will display name of form that opened report.
HTH
-
WSstever
AskWoody Lounger
-
WScharlotte
AskWoody LoungerDecember 18, 2002 at 2:12 am #639420A somewhat more reliable approach in the event that you may have several forms opened at once and might overwrite that global, is to store the information in the form itself. When you open the form, use the OpenArgs argument of the DoCmd.OpenForm call to pass in the name of the calling form. Then in the close event of the called form, just reference the form name you got as a string in OpenArgs.
-
WSClausParkhoi
AskWoody LoungerDecember 18, 2002 at 9:03 am #639477Why not do it the easy way, no global needed. In the open event of the called form:
Dim strForm as String
On Error Resume Next
strForm=Screen.ActiveForm.Name
If strForm=”” Then
…….. not opened by another form
Else
…….. opened by another form
EndifIf the form can only be opened from another form you don’t need the error trapping.
-
WSpatt
AskWoody Lounger -
WSClausParkhoi
AskWoody LoungerDecember 18, 2002 at 9:26 am #639480 -
WSpatt
AskWoody Lounger
-
-
-
-
WScharlotte
AskWoody Lounger
WSstever
AskWoody LoungerDecember 18, 2002 at 1:27 pm #639509Wow!!! What a wealth of information. It’s always great to get multiple methods to attack an issue. Each situation may need a different solution. I’m very impressed with the variety of responses, and will have to check into all the possibilities to see which one will work best for me!!
Thanks to everyone for their ideas and methods – it was more of a discussion than I had anticipated. Hopefully someday I can get to a point where I too can achieve guru status and begin answering questions such as these.
Viewing 1 reply thread -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Excessive security alerts
by
WSSebastian42
2 hours, 2 minutes ago -
* CrystalDiskMark may shorten SSD/USB Memory life
by
Alex5723
2 hours, 51 minutes ago -
Ben’s excellent adventure with Linux
by
Ben Myers
3 hours, 11 minutes ago -
Seconds are back in Windows 10!
by
Susan Bradley
4 hours, 3 minutes ago -
WebBrowserPassView — Take inventory of your stored passwords
by
Deanna McElveen
4 hours, 3 minutes ago -
OS news from WWDC 2025
by
Will Fastie
4 hours, 5 minutes ago -
Need help with graphics…
by
WSBatBytes
2 hours, 46 minutes ago -
AMD : Out of Bounds (OOB) read vulnerability in TPM 2.0 CVE-2025-2884
by
Alex5723
18 hours, 18 minutes ago -
Totally remove or disable BitLocker
by
CWBillow
17 hours, 12 minutes ago -
Windows 10 gets 6 years of ESU?
by
n0ads
5 hours, 8 minutes ago -
Apple, Google stores still offer China-based VPNs, report says
by
Nibbled To Death By Ducks
1 day, 5 hours ago -
Search Forums only bring up my posts?
by
Deo
1 day, 5 hours ago -
Windows Spotlight broken on Enterprise and Pro for Workstations?
by
steeviebops
1 day, 16 hours ago -
Denmark wants to dump Microsoft for Linux + LibreOffice
by
Alex5723
1 day, 9 hours ago -
How to get Microsoft Defender to honor Group Policy Setting
by
Ralph
1 day, 17 hours ago -
Apple : Paragon’s iOS Mercenary Spyware Finds Journalists Target
by
Alex5723
2 days, 3 hours ago -
Music : The Rose Room – It’s Been A Long, Long Time album
by
Alex5723
2 days, 4 hours ago -
Disengage Bitlocker
by
CWBillow
1 day, 18 hours ago -
Mac Mini M2 Service Program for No Power Issue
by
Alex5723
2 days, 6 hours ago -
New Win 11 Pro Geekom Setup questions
by
Deo
1 day, 5 hours ago -
Windows 11 Insider Preview build 26200.5651 released to DEV
by
joep517
2 days, 13 hours ago -
Windows 11 Insider Preview build 26120.4441 (24H2) released to BETA
by
joep517
2 days, 13 hours ago -
iOS 26,, MacOS 26 : Create your own AI chatbot
by
Alex5723
2 days, 17 hours ago -
New PC transfer program recommendations?
by
DaveBoston
22 hours, 45 minutes ago -
Windows 11 Insider Preview Build 22631.5545 (23H2) released to Release Preview
by
joep517
2 days, 21 hours ago -
Windows 10 Build 19045.6029 (22H2) to Release Preview Channel
by
joep517
2 days, 21 hours ago -
Best tools for upgrading a Windows 10 to an 11
by
Susan Bradley
2 days, 10 hours ago -
The end of Windows 10 is approaching, consider Linux and LibreOffice
by
Alex5723
1 day, 14 hours ago -
Extended Windows Built-in Disk Cleanup Utility
by
bbearren
1 day, 23 hours ago -
Win 11 24H2 June 2025 Update breaks WIFI
by
dportenlanger
3 days, 16 hours ago
Recent blog posts
- Ben’s excellent adventure with Linux
- Seconds are back in Windows 10!
- WebBrowserPassView — Take inventory of your stored passwords
- OS news from WWDC 2025
- Best tools for upgrading a Windows 10 to an 11
- Master patch listing for June 10, 2025
- 24H2 may not be offered June updates
- June 2025 updates are out
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.