Get Form Name

LB79

Registered User.
Local time
Today, 01:33
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
 
Me.Name is the form name.

For instance, use MsgBox Me.Name.

-dK
 
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?
 
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
 
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

Back
Top Bottom