By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,045 Members | 1,760 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,045 IT Pros & Developers. It's quick & easy.

How to enable specific buttons on form list?

P: 11
I have a form with a list (as per attached image) and a formula that according if the box is checked it either enables the button or disables it. I have implemented this on form load. But the issue is that although the formula works, it either enables or disables all of the form buttons on the list. What am I doing wrong?

Attached Images
File Type: jpg CaptureAccess.JPG (28.4 KB, 62 views)
1 Week Ago #1

✓ answered by twinnyfo

nsiotto,

You are doing nothing wrong--it simply has to do with how Access formats forms being using in Contiuous Forms view.

One way around this is to add code behind the command button, such that the status of the check box will determine whether the Event procedure continues or not. This would be as simple as:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdButton_Click()
  2.     If Me.chkBox Then Exit Sub
  3.  
  4. 'Or put "Not" after "If" depending on what 
  5. 'state requires execution of the code
  6.  
  7.     Blah Blah Blah the rest of your code
  8. End Sub
Hope this hepps!

Share this Question
Share on Google+
5 Replies


twinnyfo
Expert Mod 2.5K+
P: 3,205
nsiotto,

You are doing nothing wrong--it simply has to do with how Access formats forms being using in Contiuous Forms view.

One way around this is to add code behind the command button, such that the status of the check box will determine whether the Event procedure continues or not. This would be as simple as:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdButton_Click()
  2.     If Me.chkBox Then Exit Sub
  3.  
  4. 'Or put "Not" after "If" depending on what 
  5. 'state requires execution of the code
  6.  
  7.     Blah Blah Blah the rest of your code
  8. End Sub
Hope this hepps!
1 Week Ago #2

P: 11
Thanks.

Here's the actual code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub ChFocus()
  2. If P_Type = "C" Then
  3. Me!OpenCh.Enabled = True
  4. Else
  5. Me!OpenCh.Enabled = False
  6. End If
  7. End Sub
Even if I revert False to True either all buttons appear enabled or all unabled. Still I can't figure out.
1 Week Ago #3

twinnyfo
Expert Mod 2.5K+
P: 3,205
As I mentioned earlier it does not work that way. Rather than disabling the control, you need to prevent the control from doing what it is supposed to do, as described above.
1 Week Ago #4

NeoPa
Expert Mod 15k+
P: 31,419
It may help to read Why Values in Unbound Form Controls do not Persist.

On the other hand Twinny has already provided a perfect answer for your situation. It's hard to know what else we could add that would make it any clearer for you. Perhaps re-read what's already been posted carefully if you still struggle to follow. If, after that, you still feel stuck then try to explain exactly what is still confusing. I'm sure once you read everything already here though you should be fine.
1 Week Ago #5

NeoPa
Expert Mod 15k+
P: 31,419
Quite apart from the problems you're having with this design, now we can see the Form as you have it, it's quite clear that the design is very 'busy' and could certainly benefit from being redone.

Consider any putting any (all) unbound Controls that are in your Detail section into the Footer section instead. It would work equally well in the Header section if you prefer that, but makes more sense visually underneath (or so it seems to me certainly). Unbound Controls include any Controls that cannot be bound too, such as Command Butttons, of course.

This wouldn't get around your other issue, but it would make it a lot clearer that what you were trying to do originally makes no sense (As per the previously linked article). It would also make using the form a whole lot easier to understand.
1 Week Ago #6

Post your reply

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