ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel Form Validation in VB (https://www.excelbanter.com/excel-programming/334927-excel-form-validation-vbulletin.html)

systematic[_7_]

Excel Form Validation in VB
 

EDIT: I've just typed this out and fixed the problem for myself. I knew
it was simple - the validate form needs to be called when the
"textbox1_change" & "textbox2_change" routines are run.

I thought I would post it anyway for any other newbies who want to make
a simple form validate - as I could'nt locate a similar post on the
forum.

Cheers

s :cool:

---------------

Hi all,

Sorry to post again - but once again I have hit a brick wall and can't
find the answers I need! :( Hopefully someone can help me -

I am trying to write a form validation, which disables a button unless
two text fields have information in them. I think the answer is
simple.

Here is my code so far -

-Private Sub Userform_Initialize()

CommandButton1.Enabled = False

TextBox1.Value = ""
TextBox2.Value = ""
With ComboBox1
..AddItem "Team 1"
..AddItem "Team 2"
..AddItem "Team 3"
..AddItem "Team 4"
End With

Call userform_validate

End Sub-


-Private Sub userform_validate()

CommandButton1.Enabled = False

If TextBox1.Value < "" And TextBox2.Value < "" Then
CommandButton1.Enabled = True

End If

End Sub-

As you guys can see by my code, I'm a complete noob! I think in theory
the code is ok - but from what I can see the problem is with where the
code is placed.

Thanks


--
systematic
------------------------------------------------------------------------
systematic's Profile: http://www.excelforum.com/member.php...o&userid=25294
View this thread: http://www.excelforum.com/showthread...hreadid=388330



All times are GMT +1. The time now is 10:41 AM.

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