me.name vs me.formname

OK, there is that issue...
And a very long speech.
I think the below picture clarify all, if it is a property and if it belongs to a form or not, (but not why it doesn't work for the OP).
attachment.php
 

Attachments

  • PropertyFormname.jpg
    PropertyFormname.jpg
    74.8 KB · Views: 361
Last edited:

Attachments

  • FormName.JPG
    FormName.JPG
    40.3 KB · Views: 112
Last edited:
Someone mentioned earlier that is part of the Outlook library. Go to your references and remove any that are not strictly Access. Do you still see FormName? I don't see it in my database.

Tick Show Hidden Members - See post 16
It's a member of the default Access library - NOT Outlook

PS - how do you embed the pictures in the text?

See this link: https://www.access-programmers.co.uk/forums/showthread.php?t=194680
 
Thanks Colin
I found FormName and it works for me in A2016. However, it must be in never-never land in other versions of Access.

Make a backup of the database just in case. Then do a global change of
Me.FormName
to
Me.Form.Name

Hopefully, that will solve the problem. This may only occur because the poster is using an .mdb in A2016.
 
Someone mentioned earlier that is part of the Outlook library. Go to your references and remove any that are not strictly Access. Do you still see FormName? I don't see it in my database.
Not because I want to be rude
In some cases, the gods themselves struggle in vain, but why could the facts in the inserted image not convince you that FormName was a property in the MS Access form, it was clearly written black on white.
I have always considered you to be a person who relate to facts when it comes to MS Access.
Basically, it was very easy to test - create a new form, paste a button, and in the click event insert MsgBox (Me.FormName).
The property FormName is also in version 2000 and 97 so nothing new here.
 
OK, it is an obscure property (or an OBSCURED property, if you prefer). I was using various references to find it, and my usual MSDN sources didn't list it:

https://msdn.microsoft.com/en-us/library/office/jj249441.aspx

https://msdn.microsoft.com/en-us/library/system.windows.forms.form(v=vs.110).aspx

https://msdn.microsoft.com/en-us/library/system.windows.forms(v=vs.110).aspx

https://msdn.microsoft.com/en-us/library/system.windows.forms.form_properties(v=vs.110).aspx

The first one is specific to Access; the others are part of .Net, but the properties tend to be similar (for the most part) between the two.

I see from the pictures posted on the subject that it appears in some Object Browser lists. So for Ac2010 I opened Object Browser, right-clicked in the browser window once it was open, enabled Show Hidden Objects, and found the FormName property as an explicitly hidden string property of object-type Form. By "explicitly hidden" I mean that it was present but not in Black print - it was in Gray print (dimmed). Went back to my Ac2002, did the same, and FormName is there too, again as a string property of Form. Not dimmed in this case.

Obviously it has been around for a long time - and HIDDEN for a long time. The machine on which I had a working Ac97 died a couple of years ago and I have not tried to fix it or replace it, so I couldn't test that version. Not sure I have that kit any more anyway.

I hope I didn't abrade TOO many feelings, but when MSDN doesn't show it and Object Browser from two versions of Access doesn't show it (without some tweaking), you have to admit it is pretty obscure. So maybe I reacted a little bit to the question about how hard I looked for it. In the end, we have verified that the property has been around for a while and hidden for at least 15 years.

Perhaps, then, the original problem is that a deprecated feature finally got so deprecated as to become unusable?
 
Code:
DoCmd.Close acForm, Me.FormName

Just to say I've now tested this in both A2016 & A2010 32-bit
I tried with both ACCDB & MDB - no added references in either case
Both worked for me in both Access versions

If anyone else wants to try it, the MDB version is attached
 

Attachments

Thanks Colin that you took the time to test it in both version.
For me the case is closed, FormName is a property in MS-Access, like it or not.
 
No problem and yes I agree with your comment.

I've found that many of the hidden members work.
Some appear to be mainly intended for use by MS staff and are hidden because they aren't properly documented.
At least one, wizhook is protected and you need a 'password' to use it. If I remember correctly it's a number. I have the details stored away if anyone wants to try it.
 
I think that MS really doesn't want us to use this property.

As I posted earlier, when I turned on the show hidden objects, I could see it. Then I went to the immediate window again and got intellisense and could print it. HOWEVER, I went back to the database today and couldn't see it again. So I went and turned on the show hidden objects and could see it AND it worked. When I turn off the show hidden objects, I CANNOT see it and it does not work. It would appear that the show hidden objects must be on to enable the property.

I think making the code change I suggested will bring you into the 21st century and solve the problem.
 
I'm with Pat. Those experiments tell me that .FormName is "on a list" that should not be used in general circumstances. Whether or not it is a property, it would appear that MS went to at least some effort to hide it and they DO NOT document it in their own developer resource pages.

However, I do not dispute that it exists.
 
As I posted earlier, when I turned on the show hidden objects, I could see it. Then I went to the immediate window again and got intellisense and could print it. HOWEVER, I went back to the database today and couldn't see it again. So I went and turned on the show hidden objects and could see it AND it worked. When I turn off the show hidden objects, I CANNOT see it and it does not work. It would appear that the show hidden objects must be on to enable the property.

Just to throw in the mix - perhaps earlier versions of Access left 'show hidden objects' as true if selected and in later versions it defaults to false on opening?
 
So I went and turned on the show hidden objects and could see it AND it worked. When I turn off the show hidden objects, I CANNOT see it and it does not work. It would appear that the show hidden objects must be on to enable the property.

That was partly my point in an earlier post. Whether or not you use a hidden property in a database, show hidden members is switched off when you open a db... which is irritating.

However, you can still use hidden properties whether or not they are visible.
And I've checked this on two computers. The code works for me whether or not the hidden properties are visible.

Try my test db. One form, one button, one line of code. No extra refs.
The code works with hidden members ...hidden.

IMO it doesn't matter that there are other alternatives that we all use all the time and which we know work perfectly well.
The OP asked about this code and it appears to me that it should work perfectly.

MS clearly discourage using hidden properties but where they do something useful that can't be done so easily by other means, why not use them.
For example, the password protected wizhook property that performs a significant role in the V-Tools add in

Obviously that's not the case here as good alternatives do exist.

EDIT 1:
Being as I've mentioned it 3 times now, this link gives the wizhook key & a long list of some of its uses
ftp://developpez.com/cafeine/access/access_wizhook.pdf
Hopefully anyone who reads that will see there are many good reasons for using that hidden member

EDIT 2:
I'm on a roll now. More info from an Access MVP
http://www.mvp-access.es/juanmafan/wizhook/wizhook.htm
Its in French but Google translate worked perfectly on the pages I looked at

I've only tried the simplest of these items so far & some can be done using documented alternatives ...but not all AFAIK
 
Last edited:
Colin, not all hidden members are created equal. This particular member does not work when you uncheck the show hidden members option. I am not arguing that some hidden members may work, I'm sure they do and this one used to. Now, in A2016, it only works if the hidden members are shown. To me that means that Microsoft does not want you to use it. I offered a very simple solution. There is no reason to fight with Access over this particular property. Just say uncle and do a global change of Me.FormName to Me.Form.Name. At least the fix is trivial. It is usually much worse when MS decides to deprecate something.
 
Colin, not all hidden members are created equal. This particular member does not work when you uncheck the show hidden members option. I am not arguing that some hidden members may work, I'm sure they do and this one used to. Now, in A2016, it only works if the hidden members are shown. To me that means that Microsoft does not want you to use it. I offered a very simple solution. There is no reason to fight with Access over this particular property. Just say uncle and do a global change of Me.FormName to Me.Form.Name. At least the fix is trivial. It is usually much worse when MS decides to deprecate something.

As I've already stated me.formname works for me in both A2010 and A2016 with hidden members hidden. I've tested it on 2 PCs with the same result.
I'm not advocating it's use as there is a perfectly good alternative. However I see no reason why someone couldn't use it from the results I've experienced.

You say its different for you. Fair enough.
Did you try my very simple test Db in A2016?
 
As I've already stated me.formname works for me in both A2010 and A2016
If you say so I believe you but it does NOT work for me. I created a form in a database and added code to it. The code worked as long as the hidden members were displayed but failed when I hid them again.

Perhaps there is something else going on.

I would simply change the code and move on. Life is too short to fight with Microsoft over things like this. There is way too much they should do to enhance Access to ever worry about breaking something that they have decided to deprecate.

I can't help it that your example worked. It worked for me also. The exact same thing does not work in the form I created in a different database. There is some other issue and it is simply not worth all the time we have spent on this when there is a very simple solution.
 
Last edited:
Not a question.

Just for future reference, I just found a new one:
Immediate window:
Code:
?forms("About").Formname
About
?forms("About").Form.Name
About
?forms("About").Name
About
The second gives an error in an obscure environment (Windows 7, Office 2013, Access 2016 runtime)
"Me" is a reference to the form object
"Form" is also a reference to the form object

I know that Me.Name will always work

Thanks everyone!
 
Last edited:

Users who are viewing this thread

Back
Top Bottom