I will start by declaring that I have NOT tried to build a Public Module of much complexity before. So it's intricacies and limitations are foreign to me, so I apologize in advance if my question seems stupid.
I am trying to build a Module that I can place a Command Button on any Form in my DB that will get that Form's entire name string (Form/Parent/Grandparent/G
IF there is a function already in Access that allows that I am unaware of it. So my feeble attempt was
Option Compare Database
Public strFormCtlName As String
Public strFormName As String
Public strFormParentName As String
Public strFormGrParentName As String
Public strFormGreatGrParentName As String
Public strFormGreatX02GrParentName As String
Public strFormGreatX03GrParentName As String
Public strFormGreatX04GrParentName As String
Public strFormGreatX05GrParentName As String
Public strFormGreatX06GrParentName As String
Public strFormGreatX07GrParentName As String
Public strFormGreatX08GrParentName As String
Public strFormGreatX09GrParentName As String
Public Sub LVLFrmName()
On Error GoTo err_Handler
strFormName = ""
strFormParentName = ""
strFormGrParentName = ""
strFormGreatGrParentName = ""
strFormGreatX02GrParentName = ""
strFormGreatX03GrParentName = ""
strFormGreatX04GrParentName = ""
strFormGreatX05GrParentName = ""
strFormGreatX06GrParentName = ""
strFormGreatX07GrParentName = ""
strFormGreatX08GrParentName = ""
strFormGreatX09GrParentName = ""
strFormName = Form.Name
strFormParentName = Parent.Form.Name
strFormGrParentName = Parent.Parent.Form.Name
strFormGreatGrParentName = Parent.Parent.Parent.Form.Name
strFormGreatX02GrParentName = Parent.Parent.Parent.Parent.Form.Name
strFormGreatX03GrParentName = Parent.Parent.Parent.Parent.Parent.Form.Name
strFormGreatX04GrParentName = Parent.Parent.Parent.Parent.Parent.Parent.Form.Name
strFormGreatX05GrParentName = Parent.Parent.Parent.Parent.Parent.Parent.Parent.Form.Name
strFormGreatX06GrParentName = Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Form.Name
strFormGreatX07GrParentName = Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Form.Name
strFormGreatX08GrParentName = Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Form.Name
strFormGreatX09GrParentName = Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Form.Name
MsgBox "" & strFormParentName
MsgBox "" & strFormGrParentName
MsgBox "" & strFormGreatGrParentName
MsgBox "" & strFormGreatX02GrParentName
MsgBox "" & strFormGreatX03GrParentName
MsgBox "" & strFormGreatX04GrParentName
The message boxes I used to just display if I was getting anything..... I didn't....
I tried it with "Me." in front of all the names ie Me.Form.Name ..... However, as you Experts know that doesn't work either...
On my Form I placed a Command Button that simply Calls LVLFrmName
Oh... By the way.... No I don't have any form that I have 6 7 8 or 9 layers of subforms but I put that in just in case I got carried away :-)