View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
systematic[_7_] systematic[_7_] is offline
external usenet poster
 
Posts: 1
Default 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

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

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