ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Greying out the OK button (https://www.excelbanter.com/excel-programming/344759-greying-out-ok-button.html)

Jeff M[_6_]

Greying out the OK button
 
I have a form that my users fill out. I want the OK button greyed out
until they fill out the form perfectly. At this point, I have
simplified it down to the following:

Private Sub UserForm_Activate()
btnOK.Enabled = False
End Sub

Private Sub txtEnd_AfterUpdate()
If Not IsNull(txtStart) And Not IsNull(txtEnd) Then
btnOK.Enabled = True
End If
End Sub

The problem is the OK button disables fine, but it never enables. When
I step through the code, it enables. Its like the code doesn't have
enough time to "darken in" the OK button, so it skips it unless the
slow human is doing the processing.

What I am doing wrong?


K Dales[_2_]

Greying out the OK button
 
I tested out your code as written and it worked fine for me. Excel 2000 on
Win 2000.
--
- K Dales


"Jeff M" wrote:

I have a form that my users fill out. I want the OK button greyed out
until they fill out the form perfectly. At this point, I have
simplified it down to the following:

Private Sub UserForm_Activate()
btnOK.Enabled = False
End Sub

Private Sub txtEnd_AfterUpdate()
If Not IsNull(txtStart) And Not IsNull(txtEnd) Then
btnOK.Enabled = True
End If
End Sub

The problem is the OK button disables fine, but it never enables. When
I step through the code, it enables. Its like the code doesn't have
enough time to "darken in" the OK button, so it skips it unless the
slow human is doing the processing.

What I am doing wrong?



Jeff M[_6_]

Greying out the OK button
 
Hmmmm. I have Excel 2000 on W2K as well. I just checked and I have
Office 2000 original issue (never been patched). I think I'll patch it
and try again.


Jeff M[_6_]

Greying out the OK button
 
Well, I patched Office and Windows and still no go.


Tom Ogilvy

Greying out the OK button
 
I can't explain your problem, but your next problem will be with using
ISNULL.


? isnull("AA")
False
? isnull("")
False

It will always return false unless you have a true NULL (not empty string)
in the cell.



--
Regards,
Tom Ogilvy



"Jeff M" wrote in message
oups.com...
Hmmmm. I have Excel 2000 on W2K as well. I just checked and I have
Office 2000 original issue (never been patched). I think I'll patch it
and try again.




Tushar Mehta

Greying out the OK button
 
Instead of disabling the OK button until the form is filled in
correctly, use it to validate the contents of the form.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article . com,
says...
I have a form that my users fill out. I want the OK button greyed out
until they fill out the form perfectly. At this point, I have
simplified it down to the following:

Private Sub UserForm_Activate()
btnOK.Enabled = False
End Sub

Private Sub txtEnd_AfterUpdate()
If Not IsNull(txtStart) And Not IsNull(txtEnd) Then
btnOK.Enabled = True
End If
End Sub

The problem is the OK button disables fine, but it never enables. When
I step through the code, it enables. Its like the code doesn't have
enough time to "darken in" the OK button, so it skips it unless the
slow human is doing the processing.

What I am doing wrong?




All times are GMT +1. The time now is 07:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com