Run-Time Error 424

Reply

Join Date: Apr 2005
Posts: 4
Reputation: bkhindri is an unknown quantity at this point 
Solved Threads: 0
bkhindri bkhindri is offline Offline
Newbie Poster

Run-Time Error 424

 
0
  #1
Apr 8th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Run-Time Error 424

 
0
  #2
Apr 8th, 2005
Are you sure the command button is named properly? Maybe attach the entire project as a zip?
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 32
Reputation: MrConfused is an unknown quantity at this point 
Solved Threads: 0
MrConfused MrConfused is offline Offline
Light Poster

Re: Run-Time Error 424

 
0
  #3
Apr 9th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 4
Reputation: bkhindri is an unknown quantity at this point 
Solved Threads: 0
bkhindri bkhindri is offline Offline
Newbie Poster

Re: Run-Time Error 424

 
0
  #4
Apr 13th, 2005
Originally Posted by Comatose
Are you sure the command button is named properly? Maybe attach the entire project as a zip?
Comatose,
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 4
Reputation: bkhindri is an unknown quantity at this point 
Solved Threads: 0
bkhindri bkhindri is offline Offline
Newbie Poster

Re: Run-Time Error 424

 
0
  #5
Apr 13th, 2005
Comatose,
I am attaching the zipped file. Thanks for your help.
Attached Files
File Type: zip GPS Rates Update.zip (65.9 KB, 20 views)
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 32
Reputation: MrConfused is an unknown quantity at this point 
Solved Threads: 0
MrConfused MrConfused is offline Offline
Light Poster

Re: Run-Time Error 424

 
0
  #6
Apr 14th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 4
Reputation: bkhindri is an unknown quantity at this point 
Solved Threads: 0
bkhindri bkhindri is offline Offline
Newbie Poster

Re: Run-Time Error 424

 
0
  #7
Apr 17th, 2005
Referencing the sheet name before the command buttons resolved the problem. Thanks anyway.
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 32
Reputation: MrConfused is an unknown quantity at this point 
Solved Threads: 0
MrConfused MrConfused is offline Offline
Light Poster

Re: Run-Time Error 424

 
0
  #8
Apr 17th, 2005
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC