UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Error 2424 But Control Is Present!, Access 2016    
 
   
Martin Beney
post Aug 23 2019, 05:49 AM
Post#1



Posts: 17
Joined: 29-January 19



Hi guys,
I have a form with a control, a text box, on a form. When I try 'me.Events_ID' I get a 2424 error, "... microsoft access can't find".

Clicking ok to the error I then ran the following in the immediate window:-
for zz=0 to me.Controls.Count-1:?me.Controls(zz).name:next
with this output:-
Locations Name_Label
Photos_Label
Events ID
Photos
Locations Name
Locations ID

Great. The control exists. But entering this in the immediate window:-
?me.Controls("Events ID")
also fails with the 2424 error.

The question is why is the control listed in the controls collection but can't be found to reference it current value?

Thanks for any ideas.

Martin
Go to the top of the page
 
Phil_cattivocara...
post Aug 23 2019, 06:05 AM
Post#2



Posts: 351
Joined: 2-April 18



What is the real name: Events_ID or Events ID? (with space or without? )
Bad idea to put space(s) in controls'name
This post has been edited by Phil_cattivocarattere: Aug 23 2019, 06:06 AM

--------------------
Please forgive in advance my horrible English.
Go to the top of the page
 
Martin Beney
post Aug 23 2019, 06:45 AM
Post#3



Posts: 17
Joined: 29-January 19



Hi,
It's with the space, the underscore is just the standard system generated replacement character.

As a note I get the error whether using me.Events_ID or me.controls("Events ID") or me.controls("Events ID").value, so they are all pointing to the same object!

All very odd

Martin
Go to the top of the page
 
Phil_cattivocara...
post Aug 23 2019, 07:24 AM
Post#4



Posts: 351
Joined: 2-April 18



OK. When do you get error? Opening the form or when you execute code?

--------------------
Please forgive in advance my horrible English.
Go to the top of the page
 
dale.fye
post Aug 23 2019, 07:27 AM
Post#5



Posts: 160
Joined: 28-March 18
From: Virginia


Personally, I prefer to prefix all my controls with an identifier which makes it clear what type of control it is.

This has the added advantage that it eliminates confusion of whether I'm referring to the control, or a field in the forms RecordSource.

I agree that you should eliminate the space from the controls name property.

Have you tried a save backup, decompile, compile, Compact and Repair? I occasionally, run into a similar situation where intellisense doesn't recognize a control name, and running through this sequence of steps generally resolves the problem.

--------------------
Dale Fye
Microsoft Access MVP 2013-2016
Developing Solutions, LLC
Go to the top of the page
 
Martin Beney
post Aug 23 2019, 08:07 AM
Post#6



Posts: 17
Joined: 29-January 19



To all,
My style is my style! It really doesn't make a bit of difference to the problem.

Read the original post. The controls collection contains a controls as named. The controls collection name is accessable. The value IS NOT. That's it.

So how can you have a control with a non accessable value?
Go to the top of the page
 
GroverParkGeorge
post Aug 23 2019, 08:12 AM
Post#7


UA Admin
Posts: 35,690
Joined: 20-June 02
From: Newcastle, WA


Plus one on the advice to eliminate spaces in control names.

That goes for table names, field names, etc. Access "can" handle" them when provided with adequate delimiters to identify them properly. On the other hand, they contribute to ambiguity and ambiguity is not a good thing in Data Management Applications. In addition, non-standard characters like # / or ? are bad news in object names, so we should get rid of them as well.

Over the years, it has become quite clear to me that Access is capable of some amazing feats of data management, but the harder we make it (by introducing ambiguity in object names, for example) the less fun it is to work with Access because we're constantly battling small distractions like the one we're talking about now.

I'm sure if you follow Dale's advice and get it stable, then remove the non-standard characters and spaces, you'll have better experiences going forward.

--------------------
My Real Name Is George. Grover Park Consulting is where I do business.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
cheekybuddha
post Aug 23 2019, 09:24 AM
Post#8


UtterAccess VIP
Posts: 11,487
Joined: 6-December 03
From: Telegraph Hill


QUOTE
Great. The control exists. But entering this in the immediate window:-
?me.Controls("Events ID")
also fails with the 2424 error.

This will only work (and even then not guaranteed) if you are stopped at a breakpoint in code within your form's module.

Otherwise, the Immediate Window does not know what is 'Me'.

Perhaps try:
CODE
?Forms.YourFormName.Controls("Events ID")

?Forms.YourFormName.[Events ID]


In your form's module you can try to use:
CODE
Me.[Events ID]


If all this fails, then try Decompile/C&R/Compile as Dale suggests.

QUOTE
My style is my style! It really doesn't make a bit of difference to the problem.

No-one is criticising your style, just trying to help solve your problem since a great many of us have learnt the hard way that spaces in object names are just not worth it.

hth,

d

--------------------


Regards,

David Marten
Go to the top of the page
 
GroverParkGeorge
post Aug 23 2019, 11:29 AM
Post#9


UA Admin
Posts: 35,690
Joined: 20-June 02
From: Newcastle, WA


As Phil gently pointed out, to Access, spaces are not always "seen" as spaces and may be represented as the underscore character in some contexts. And that possibility must be considered as a potential aspect of the current problem. It's just good sense to consider everything that could be relevant.

That's also one of the reasons most seasoned Access developers have evolved away from allowing spaces and non-standard characters in object names. It eventually makes your life easier when you have to support an Access Database Application over several years, and when you have to trouble-shoot it.

That said, it's entirely up to you what naming convention you adopt, if any. Each convention comes with its own strengths and weaknesses, though.

--------------------
My Real Name Is George. Grover Park Consulting is where I do business.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
Martin Beney
post Aug 25 2019, 05:43 AM
Post#10



Posts: 17
Joined: 29-January 19



Its quite fascinating how replies love to go off topic.

No one has an answer so don't answer.

I really had the wrong impression of Q&A style forums as somewhere to find answers.

Oh yes I have been coding since the early 70's and running access code since the late 80's. But maybe that's not seasoned enough!

Regards
Martin
Go to the top of the page
 
mike60smart
post Aug 25 2019, 06:16 AM
Post#11


UtterAccess VIP
Posts: 13,369
Joined: 6-June 05
From: Dunbar,Scotland


Hi

If "Your Style" is your style then go ahead and solve it using your style is all I can offer. Luck with the project.

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
cheekybuddha
post Aug 25 2019, 06:22 AM
Post#12


UtterAccess VIP
Posts: 11,487
Joined: 6-December 03
From: Telegraph Hill


Did you try my suggestions? What was the result?

--------------------


Regards,

David Marten
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    21st September 2019 - 08:41 PM