Get Form Name (1 Viewer)

LB79

Registered User.
Local time
Today, 05:27
Joined
Oct 26, 2007
Messages
505
Hello,

I'm trying to create a simple function that gives me the current form name.
I have a public variable that I want to store the name in before using it in a msgbox.
I've looked at some examples but they aren’t clear to me. One in particular was frmName = Me.Name
Can anyone please tell me the correct version of frmName = Me.Name?

Thanks
 

dkinley

Access Hack by Choice
Local time
Yesterday, 23:27
Joined
Jul 29, 2008
Messages
2,016
Me.Name is the form name.

For instance, use MsgBox Me.Name.

-dK
 

LB79

Registered User.
Local time
Today, 05:27
Joined
Oct 26, 2007
Messages
505
Thanks for replying - I guess my problem is elsewhere...

My default form (switchboard) has the following:
Code:
Public ErrFormName As String

I have a public function that has the following code:
Code:
Public Sub Error()
MsgBox ErrFormName
End Sub

And when the error handler is triggered the code is:
Code:
Private Sub Command1_Click()
On Error GoTo ATMT_Err
DoCmd.OpenForm "me" ' This is a purpose caused error
Exit Sub
ATMT_Err:
ErrFormName = Me.Name
Call Error
End Sub

But when the MSGBOX shows, its completely blank. Can you see what Im doing wrong?
 

vbaInet

AWF VIP
Local time
Today, 05:27
Joined
Jan 22, 2010
Messages
26,374
Couple of things:

1. Don't call a function or anything in Access the word "ERROR"
2. Avoid the spaghetti coding, calling another code whilst in error
3. Look into the CodeContextObject
 

LB79

Registered User.
Local time
Today, 05:27
Joined
Oct 26, 2007
Messages
505
Thanks
1 - Noted.
2 - I want the code in one place so that all the forms can use the same basic structure rather then having the entire error coding in every form.
3 - I shall look.
 

Users who are viewing this thread

Top Bottom