Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts
    Hi

    I am developing a userform in Word to collect information for input into a template.

    I am having trouble with the code to ensure that required text boxes are completed.

    I have used hte following code:

    If txtClientNo.Text = False Then
    MsgBox ("You must enter a Client Number")
    Exit Sub
    Else
    Selection.GoTo what:=wdGoToBookmark, Name:="ClientNo"
    Selection.TypeText Text:=txtClientNo
    End If

    for each textbox.

    However, when I run the code it seems to only accept integer input.i.e. If I input any text entries I get the MSG box pop up to say the field must be completed.

    Anyone any suggestions?
    cheers

    Phil Carter

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,436
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Assuming that this is a text box you would:

    Code:
    If txtClientNo.Text = "" Then
         MsgBox ("You must enter a Client Number")
         txtClientNo.SetFocus
         Exit Sub
    Else
         Selection.GoTo what:=wdGoToBookmark, Name:="ClientNo"
         Selection.TypeText Text:=txtClientNo
    End If
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. #3
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts
    Hi

    Thanks for that. Works just fine,

    I had overlooked that way of checking for an empty textbox. Tried "0", "False" and turning the if statement around to check if true then...
    cheers

    Phil Carter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •