468,253 Members | 1,232 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,253 developers. It's quick & easy.

changing properties seems 'invisible' in subprocedure

Can anyone explain this strange behavior?

On an access form (access 2010), I have a line to change the enabled property in the "on_click()" event which disables the command button. The exact code is me!cmdaddNew.enabled=false. This does fine to disable the button. However, in the onexit() event for the same command button, I put a line(as shown below) to restore the status of the button to true. I have written some extra code that adjusts some unbound text boxes on the form which look like this:

Expand|Select|Wrap|Line Numbers
  1. Me!txtcheckNumber = ""
  2. Me!txtpaymentAmt = Default
  3. Me!chkpaymentLate = 0
  4. Me!txtpaymentDate = Date
  5. Me!cmdaddNew.enabled=true
All of the code executes fine EXCEPT FOR re-enabling the command button. It compiles fine and executes with no run-time error messages, but it seems to completely ignore the one line of code to restore the enabled property. Just to be as clear as possible, the onclick() event also updates tables with a recordset object which works fine. I am still not really adept enough with debugging tools for them to be a lot of assistance. Any reply (or suggestion) would be greatly appreciated!
Jul 27 '14 #1
3 848
3,650 Expert Mod 2GB
Have you tried inserting a breakpoint in your code and gone through line by line when it executes (F8)? This would tell you if the code is actually trying to enable the control or if it just "appears that the other code is running and omitting this one line.
Jul 28 '14 #2
I believe that I will try to use some 'breakpoint' techniques to debug this issue. I suspect that it is not a good idea (in general) to disable the current command button in an onexit() subprocedure, and then try to reset this with another 'focus' event. I even tried to 'reinstate' the enabled property of the button through a general form click() event, and this doesn't work. Since all of my textboxes to update data are unbound, this might add another complication if I try to invoke the re-enabling through a form after update() event. There must be a general coding process which does this in a fairly routine way. It would seem to be some functionality that anyone would wish to have on a form with a command button. Thank you for the advice and I still would appreciate any and all suggestions on this matter.
Jul 28 '14 #3
5,400 Expert Mod 4TB
When you set your
Expand|Select|Wrap|Line Numbers
  1. stop
do so at the start of your onclick event.

What you are goint to see is that as soon as you "disable" the command button, the onexit event triggers... you have in effect, left the command button at that point.

It's all in the timing... watch as I pull a Rabbit, err, Frog, err, Hamster... there it is, out of the Hat. (^_^)
Jul 28 '14 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Tony W | last post: by
1 post views Thread by Tobe | last post: by
12 posts views Thread by Nico Schuyt | last post: by
1 post views Thread by libsfan01 | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.