PDA

View Full Version : CommandBtn Enabled, won't click



wnazzaro
10-13-2006, 06:40 AM
Hello again,

I have this perplexing problem. I have a CommandButton that I can't click. I can most of the time, but after I run one Sub, it locks and is unselectable. I checked the Enabled property (with a MsgBox) and it returns True. The button works in general, it only locks in one iteration of my form.

Any ideas what property or reason might be causing this?

I could attach the db if you want to take a look.

Kind regards,
Bill

OBP
10-13-2006, 11:17 AM
Hello Bill, can you post a zipped copy on here, it doesn't need much data just a dummy record or two will do?
Have you tried forcing the command button to be enabled?

wnazzaro
10-14-2006, 06:15 AM
I will add the .zip on Monday (it's at work). I did add a cmdBtn.Enabled = True to the Sub and it didn't have any effect.

Thanks.

wnazzaro
10-17-2006, 07:45 AM
Database attached.

Update: I'm losing my mind. It will help here if I describe how to create the error. First, the form is still a bit buggy, so please forgive that. The problem I can't figure out is with the button named 'Show class attendees'

Open the form 'Data entry form.' You will see the button on the bottom. It's works as expected from this view.

Now click on 'Find/Add/Edit user.' Then 'Show associated courses.' Now try the 'Show class attendees' button. It is locked and I can't figure out why. That's the problem I need help with.

The view where the button locks is the Sub 'ShowUsers.'

OBP
10-17-2006, 08:07 AM
Bill, which form is the button on?
Ok found it!
I will let you know as soon as I have had a look.

OBP
10-17-2006, 08:09 AM
Bill, which button has the problem?

wnazzaro
10-17-2006, 08:11 AM
Sorry, read my updated post.

OBP
10-17-2006, 08:15 AM
Bill, sorry, I dived straight in instead of reading. http://vbaexpress.com/forum/images/icons/icon11.gif

wnazzaro
10-17-2006, 08:17 AM
Not your fault at all. I attached the db without explaining the exact problem or how to create it. Thanks.

OBP
10-17-2006, 08:24 AM
Bill, do you do all your form inputs etc with VBA?
This is the second time I have seen this where everything is controlled by VBA rather than just using different forms or different versions of the same form.

OBP
10-17-2006, 08:33 AM
Bill, this is so complicated I don't understand why you are using buttons to call macros to call functions to call other functions.
It would be far more streamlined if the Command button just used the VBA from the functions.
As to your actual problem, about the only thing that I can think of is that the 2 functions in question both use the the same recordset, so you may have a record locking type conflict.
Have you tried actually closing the first recordset in the "show users" function?

OBP
10-17-2006, 08:42 AM
Bill, what links the Users to the courses?
I have tried to enter course data for a selected user, which it does (it is in the table) but when I recall the user the course is not associated with that record.

wnazzaro
10-17-2006, 09:05 AM
Bill, this is so complicated I don't understand why you are using buttons to call macros to call functions to call other functions.
It would be far more streamlined if the Command button just used the VBA from the functions.

Novice error. I don't do much in Access, so when I started this I was trying to figure out how to make it work, without knowing what I needed to do. That's why it turned out the way it did.

OBP
10-17-2006, 09:13 AM
Bill, are you a VB6 programmer?
You are working really well with the VBA but most of it could be replaced by the more normal query/form methods for presenting and linking the data.
I still haven't found why the button won't work other than there are no records associated with the selected user, but I don't know why that would stop it when it works with other combinations of buttons. :dunno

wnazzaro
10-17-2006, 10:24 AM
Bill, are you a VB6 programmer?
You are working really well with the VBA but most of it could be replaced by the more normal query/form methods for presenting and linking the data.


I'm a tuba player by training. Everything I know in VBA is book learning and with the help of this forum. The reason I did everything in code is the association of classes to users. The associate button adds a reference to the course in the training column "Classes_Taken". I figured since this had to be in code, I would try to do everything with one form. In general it works, except this strange button issue. I've only worked on this for the past week or so, so with time I think I can straighten all the bugs out. The only thing that has me scratching my head is this button.

What do you mean by "the more normal query/form methods?" Do you mean using multiple forms instead of one form? I do most writing in Excel, so getting used to Access is always a bit of a pain.

Thanks,
Bill

wnazzaro
10-17-2006, 10:32 AM
Bill, what links the Users to the courses?
I have tried to enter course data for a selected user, which it does (it is in the table) but when I recall the user the course is not associated with that record.

The other thing I've noticed is that the form works better with the original data I had. When the data is removed, strange bugs pop up. If you scroll through the records of users and their courses, the second record should update correctly. Going back to the first then shows the courses they are associated with and a tick box to delete the course. When I have time to fix all the bugs, I will update the attachment.

OBP
10-18-2006, 12:35 PM
Bill, here is an example of a fairly typical database based on your data.
It was practically all created using Access wizards.