LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default moving within forms

Hi,

I assume you have a button on your userform that closes it and does
something with the values. This code would be called by that button. It loops
through each textbox on the form and ensure the value is numeric and in
addition if textbox 3 is populated it checks if textbox1 is

Private Sub CommandButton1_Click()
Dim cCont As Control
For Each cCont In Me.Controls
If TypeName(cCont) = "TextBox" Then
With cCont
If Not IsNumeric(.Value) And .Value < vbNullString Then
MsgBox cCont.Name & " value must be numeric"
.Value = vbNullString
End If
End With
End If

'Ensure box 1 is populated if box 3 has a value
If cCont.Name = "TextBox3" And cCont.Value < _
vbNullString And TextBox1.Value = vbNullString Then
MsgBox "Text Box 1 cannot be empty with a value in textbox 3"
End If
Next cCont
End Sub

Mike

"TC" wrote:

Hi All.

I have a user form that acts as an inputbox, and there are 6 fields withing
the form.
None of the fields require any input - they can be left blank, but if a
value is input, it must be numeric. However, if there is a value entered into
say field3 then a value IS required for field1. So if field1 is blank, I give
an error message. What I need to do, once the error message is closed, is
place the cursor back into field1 so the user can type something in. I can't
find any code within VB that will do that!

thanks
TC



 
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
Moving text around cells without moving boarder lines Dale Excel Discussion (Misc queries) 1 December 15th 09 06:14 PM
Arrow Keys Moving Window Frame instead of Moving Between Cells nemmex Excel Discussion (Misc queries) 2 April 9th 07 09:08 AM
Excel forms - authorise / deny forms Ian Manning Excel Programming 1 May 8th 06 05:03 PM
RefEdits and normal forms / forms in a DLL David Welch Excel Programming 0 December 1st 04 03:49 PM
Calling Forms from Forms - Exit problems Stuart[_5_] Excel Programming 3 May 25th 04 06:50 AM


All times are GMT +1. The time now is 12:39 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"