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
> Control Name In Macro Misspelled Or Does Not Exist, Access 2016    
 
   
tonytlc
post Jan 3 2018, 09:44 AM
Post#1



Posts: 36
Joined: 19-May 09
From: Leicestershire UK


Hi. I haven't been online for a while because everything has been going great. At least it was until we changed from Access 2007 to Access 2016. On 2007 everything worked fine but since copying the front end over to 2016 I am getting errors especially with Macros. I have used Macros on a button to a) open a form and then to b) lock certain fields. This is because when editing I need certain fields to be inaccessible. The problem that I have is that I get an error stating that the Control name is either misspelt or does not exist. I have checked through the macro and this is certainly not the case. I have even tried creating new Macros and using them but I get the same result. If I click Stop Macros then the form opens OK but the fields I want to be locked can be edited so this is too risky. I use the Open Form Macro to open the form (and that works fine) and I use the SetProperty Macro to lock the fields. Hopefully, someone can help - please
.
PS - To make things even more confusing for me I created a brand new single macro to open the form and then lock 3 fields using 3 separate SetProperty commands. when I double click the Macro it works fine but when I add it as a 'click' action to a button the form opens but then I get the 'misspelled' message.

regards
Tony
This post has been edited by tonytlc: Jan 3 2018, 10:12 AM

--------------------
Tony@TLC
Go to the top of the page
 
ranman256
post Jan 3 2018, 10:18 AM
Post#2



Posts: 867
Joined: 25-April 14



macros dont debug well.
you could convert the macro to code. THIS will tell you where the errors are.
every macro command can be coded.

openquery = docmd.OpenQuery "query"
etc.

put them into a sub in a module .
then run the sub in place of the macro:

instead of docmd.runMacro "myMacro"
use: RunMyCode

CODE
sub RunMyCode()
txtBox.Locked = false
chkBox.value = true
end sub


the code will stop on the invalid line.
This post has been edited by ranman256: Jan 3 2018, 10:19 AM
Go to the top of the page
 
GroverParkGeorge
post Jan 3 2018, 10:47 AM
Post#3


UA Admin
Posts: 33,038
Joined: 20-June 02
From: Newcastle, WA


What would be very helpful is to SEE the actual Macro(s), and especially the forms and controls. That's where this "misspelling" would occur and that's what we need to diagnose the problem.

Can you provide a sample of the accdb? Do a compact & repair. Include just enough sample data--without confidential or sensitive data--to see how it needs to work. Compact it into a ZIP file and attach it as an upload.

Thanks.

--------------------
Go to the top of the page
 
tonytlc
post Jan 4 2018, 08:22 AM
Post#4



Posts: 36
Joined: 19-May 09
From: Leicestershire UK


Hi.
Thanks for the offer but it is difficult for me to strip the data back and, in any case, we work with vulnerable people so any data going out of the building is a no no. What is really weird though is that I have now created a brand new Macro in 2016. When I run the macro everything works fine but when I apply the macro as an 'On Click' event on a button I get the error messages and have to stop all macros. Do you think I am correct in thinking it is the design of the form? Oops, cancel that. I have just created a brand new form, added a button and attached the Macro to the button. Same result in that the macro runs fine on its own but delivers an error when attached to the button. I have also tried creating a button with an embedded macro and the same happens.
Tony
This post has been edited by tonytlc: Jan 4 2018, 08:30 AM

--------------------
Tony@TLC
Go to the top of the page
 
cheekybuddha
post Jan 4 2018, 08:27 AM
Post#5


UtterAccess VIP
Posts: 10,141
Joined: 6-December 03
From: Telegraph Hill


Perhaps not the answer you are looking for, but it's probably easier at this stage to ditch [IMHO almost useless] macros and use VBA code instead.

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


Regards,

David Marten
Go to the top of the page
 
GroverParkGeorge
post Jan 4 2018, 08:59 AM
Post#6


UA Admin
Posts: 33,038
Joined: 20-June 02
From: Newcastle, WA


Okay, how about some screen shots showing the entire macro in design view and the table(s) involved in design view, and perhaps the form. Maybe someone can see something that way.

Otherwise, trying to diagnose this is a lot like asking your auto mechanic to tell you what's wrong with your car--over the phone.


--------------------
Go to the top of the page
 
tonytlc
post Jan 5 2018, 07:09 AM
Post#7



Posts: 36
Joined: 19-May 09
From: Leicestershire UK


Hi.
sadly this is the conclusion I have come to. It may be a pain but it will probably be quicker than trying to solve the problem. Trouble my ability with VBA is close to zero so it looks like another "....for Dummies" book.

--------------------
Tony@TLC
Go to the top of the page
 
GroverParkGeorge
post Jan 5 2018, 07:29 AM
Post#8


UA Admin
Posts: 33,038
Joined: 20-June 02
From: Newcastle, WA


There must be a valid reason for the problem here. Let's not give up quite yet.

Can you not provide a screen shot of the macro(s0 and the form(s)?

--------------------
Go to the top of the page
 
JonSmith
post Jan 5 2018, 09:53 AM
Post#9



Posts: 3,576
Joined: 19-October 10



I did find that VBA got less forgiving and you sometimes needs to be more explicit in code. This happened when updating from 2010 to 2013 and in Excel some sloppy code needed some more specific declarations to work rather that just being able to find the objects it needed.

Its possible the same is true of Macros in Access or that somehow they are using VBA which is less forgiving?
Like George said screenshots etc could help us guess at the problem but Dave is valid in saying its worth switching to VBA, its always a good time to start learning and imo they are easier to learn than macros.
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    19th July 2018 - 11:37 PM