Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Help !!! My code is not working as expected.

The following snippet of code is suppose to loop through all the
CommandButton controls on a Multipage control on a form and change the
Enabled property of those CommandButton to True if there is a Value in the
ComboBox "cmbDrive". Otherwise the CommadButton controls should be Disabled.

My problem is that I keep getting an "Object required" error message. I
don't know what I did wrong. If there is anyone out there that knows what is
wrong or how I can code this better, please HELP !!!

Private Sub cmbDrive_AfterUpdate()
If cmdDrive.Text < "" Then
For Each ctl In frmOpenFiles.Controls
If TypeName(ctl) = "CommandButton" And ctl.Enabled = False Then
ctl.Enabled = True
End If
Next ctl
ElseIf cmdDrive.Value = "" Then
For Each ctl In frmOpenFiles.Controls
If TypeName(ctl) = "CommandButton" And ctl.Caption < "Cancel"
Then
ctl.Enabled = False
End If
Next ctl
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 227
Default Help !!! My code is not working as expected.

Your statement of the problem refers to a ComboBox called "cmbDrive,"
but your code references "cmdDrive." That is, the third letter is
different. Does the code use the correct control name?

Mark Lincoln

On Aug 30, 3:20 pm, Ayo wrote:
The following snippet of code is suppose to loop through all the
CommandButton controls on a Multipage control on a form and change the
Enabled property of those CommandButton to True if there is a Value in the
ComboBox "cmbDrive". Otherwise the CommadButton controls should be Disabled.

My problem is that I keep getting an "Object required" error message. I
don't know what I did wrong. If there is anyone out there that knows what is
wrong or how I can code this better, please HELP !!!

Private Sub cmbDrive_AfterUpdate()
If cmdDrive.Text < "" Then
For Each ctl In frmOpenFiles.Controls
If TypeName(ctl) = "CommandButton" And ctl.Enabled = False Then
ctl.Enabled = True
End If
Next ctl
ElseIf cmdDrive.Value = "" Then
For Each ctl In frmOpenFiles.Controls
If TypeName(ctl) = "CommandButton" And ctl.Caption < "Cancel"
Then
ctl.Enabled = False
End If
Next ctl
End If
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.misc
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Help !!! My code is not working as expected.

Thanks Mike. That fixed it.

"Mark Lincoln" wrote:

Your statement of the problem refers to a ComboBox called "cmbDrive,"
but your code references "cmdDrive." That is, the third letter is
different. Does the code use the correct control name?

Mark Lincoln

On Aug 30, 3:20 pm, Ayo wrote:
The following snippet of code is suppose to loop through all the
CommandButton controls on a Multipage control on a form and change the
Enabled property of those CommandButton to True if there is a Value in the
ComboBox "cmbDrive". Otherwise the CommadButton controls should be Disabled.

My problem is that I keep getting an "Object required" error message. I
don't know what I did wrong. If there is anyone out there that knows what is
wrong or how I can code this better, please HELP !!!

Private Sub cmbDrive_AfterUpdate()
If cmdDrive.Text < "" Then
For Each ctl In frmOpenFiles.Controls
If TypeName(ctl) = "CommandButton" And ctl.Enabled = False Then
ctl.Enabled = True
End If
Next ctl
ElseIf cmdDrive.Value = "" Then
For Each ctl In frmOpenFiles.Controls
If TypeName(ctl) = "CommandButton" And ctl.Caption < "Cancel"
Then
ctl.Enabled = False
End If
Next ctl
End If
End Sub




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 611
Default Help !!! My code is not working as expected.

Ayo,

You should use "Option Explicit" at the top of all your modules. That will catch errors
like this. In the VBE, Tools - Options - Editor tab, "Require variable declaration" will
put that in all new modules, but I don't think it changes it after the modules have been
created.

--
Earl Kiosterud
www.smokeylake.com

Note: Top-posting has been the norm here.
Some folks prefer bottom-posting.
But if you bottom-post to a reply that's
already top-posted, the thread gets messy.
When in Rome...
-----------------------------------------------------------------------
"Ayo" wrote in message
...
Thanks Mike. That fixed it.

"Mark Lincoln" wrote:

Your statement of the problem refers to a ComboBox called "cmbDrive,"
but your code references "cmdDrive." That is, the third letter is
different. Does the code use the correct control name?

Mark Lincoln

On Aug 30, 3:20 pm, Ayo wrote:
The following snippet of code is suppose to loop through all the
CommandButton controls on a Multipage control on a form and change the
Enabled property of those CommandButton to True if there is a Value in the
ComboBox "cmbDrive". Otherwise the CommadButton controls should be Disabled.

My problem is that I keep getting an "Object required" error message. I
don't know what I did wrong. If there is anyone out there that knows what is
wrong or how I can code this better, please HELP !!!

Private Sub cmbDrive_AfterUpdate()
If cmdDrive.Text < "" Then
For Each ctl In frmOpenFiles.Controls
If TypeName(ctl) = "CommandButton" And ctl.Enabled = False Then
ctl.Enabled = True
End If
Next ctl
ElseIf cmdDrive.Value = "" Then
For Each ctl In frmOpenFiles.Controls
If TypeName(ctl) = "CommandButton" And ctl.Caption < "Cancel"
Then
ctl.Enabled = False
End If
Next ctl
End If
End Sub






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Iserror not working as expected NathanG Excel Worksheet Functions 5 February 1st 07 05:31 PM
Auto Fill - working as expected? LynnS New Users to Excel 1 October 17th 06 08:20 PM
=NETWORKDAYS not working as expected and as it once did USAOz Excel Worksheet Functions 2 July 13th 06 03:02 PM
Lookup Not working as expected trumpy81 New Users to Excel 5 June 30th 05 07:41 PM
Application.Volatile not working as expected Richards Excel Discussion (Misc queries) 3 February 3rd 05 12:20 AM


All times are GMT +1. The time now is 01:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"