![]() |
| ||
| Run-Time Error 424 I am trying to use an IF statement to enable/disable command buttons; however, I get the following error message "Run Time Error '424': Object Required". The "cmdDeptStoresMC.Enabled=True" is highlighted in yellow when I run the code. Please assist. Below is my code: Sub Check_AccessRights() Dim X As String Dim Y As String X = EssVCell(Null, "Year Total", "MC", "Business Type", "Accounts", "Departments") Y = EssVCell(Null, "Year Total", "OR", "Business Type", "Accounts", "Departments") If X = "#No Access" Then cmdDeptStoresMC.Enabled = False cmdRetailStoresMC.Enabled = False Else cmdDeptStoresMC.Enabled = True cmdRetailStoresMC.Enabled = True End If If Y = "#No Access" Then cmdDeptStoresOR.Enabled = False cmdRetailStoresOR.Enabled = False Else cmdDeptStoresOR.Enabled = True cmdRetailStoresOR.Enabled = True End If End Sub |
| ||
| Re: Run-Time Error 424 Are you sure the command button is named properly? Maybe attach the entire project as a zip? |
| ||
| Re: Run-Time Error 424 I agree with Comatose. VB can't find a command button named "cmdDeptStoresMC". Either the command button name is mis-spelt, or the form which contains it is not loaded in memory. |
| ||
| Re: Run-Time Error 424 Quote:
My command buttons are named correctly. I am attaching my excel file with the VBA code. Please review and Advise. Thanks a lot for your help. |
| ||
| Re: Run-Time Error 424 1 Attachment(s) Comatose, I am attaching the zipped file. Thanks for your help. |
| ||
| Re: Run-Time Error 424 Hello again, No offence but I don't download anything to my computer unless I have to. However run time error 424 on my version of VB says "form not found". Please check the form that has the command button on you were refering to is in memory. If the form has not been loaded, or has been unloaded before the code referrs to it you will get the message you have posted about. VB cannot find the command button. Maybe your code (to do with one form) is referring to a command button on another form. If that is so then I'll have to have a think about it. Regards. |
| ||
| Re: Run-Time Error 424 Referencing the sheet name before the command buttons resolved the problem. Thanks anyway. |
| ||
| Re: Run-Time Error 424 Referencing the sheet name (i.e form) re-loads the form putting the command button in memory. The command button's form was not in memory therefore the button was not there as far as vb could find. You should note that VB is not always correct and I (and many others) have had similar problems where then answer is far more more "weird". So 98 times out of 100 the VB query is right. When it is the other 2 your hair starts falling out!! Cheers. |
| All times are GMT -4. The time now is 8:33 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC