Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default Change Procedure

lets assume i have inserted a form into my excel workbook
i put in a frame, one textbox, one combobox and one commandbutton. I want
the commandbutton to remain greyed out, so i put the property for enabled to
false. i need to have the enabled property to change back to true when all
the required information has been entered. so i have the codes like this:

Private Sub textbox_Change()
if textbox = "" or combobox = "" then
msgbox ("missing info")
else
commandbutton.enabled = true
end if
End Sub.

Private Sub combobox_Change()
if textbox = "" or combobox = "" then
msgbox ("missing info")
else
commandbutton.enabled = true
end if
End Sub

if i dont write a procedure for both control then when i do any changes on
the control that doesnt have a change procedure, the commandbutton remains
unchange. Is there another way to do this. i want to eliminate writing so
many sub procedures.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 132
Default Change Procedure

Ernie, write one procedure that checks all your controls and call that
procedure from each event.


private sub ValidateControls()
if ((textbox = "") or (combobox = "")) then
msgbox ("missing info")
commandbutton.enabled = false ' reset if something is deleted
else
commandbutton.enabled = true
end if
End sub


Private Sub combobox_Change()
ValidateControls
end sub

Private Sub textbox_Change()
ValidateControls
end sub


"ernie" wrote:

lets assume i have inserted a form into my excel workbook
i put in a frame, one textbox, one combobox and one commandbutton. I want
the commandbutton to remain greyed out, so i put the property for enabled to
false. i need to have the enabled property to change back to true when all
the required information has been entered. so i have the codes like this:

Private Sub textbox_Change()
if textbox = "" or combobox = "" then
msgbox ("missing info")
else
commandbutton.enabled = true
end if
End Sub.

Private Sub combobox_Change()
if textbox = "" or combobox = "" then
msgbox ("missing info")
else
commandbutton.enabled = true
end if
End Sub

if i dont write a procedure for both control then when i do any changes on
the control that doesnt have a change procedure, the commandbutton remains
unchange. Is there another way to do this. i want to eliminate writing so
many sub procedures.

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
Event procedure for change of a particular cell? Chet Excel Programming 5 July 19th 06 08:25 PM
change event procedure natanz[_2_] Excel Programming 0 November 4th 05 03:42 AM
Change of workbook procedure magnus Excel Programming 0 November 12th 04 06:39 PM
change event procedure benb Excel Programming 2 September 24th 04 09:22 PM
Worksheet change sub procedure Grant Excel Programming 5 September 24th 04 01:44 AM


All times are GMT +1. The time now is 12:22 AM.

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"