+ Reply to Thread
Results 1 to 5 of 5

Message Box if any of userform textbox are empty

Hybrid View

Rey Ocampo Message Box if any of... 11-14-2012, 04:25 PM
AlphaFrog Re: Message Box if any of... 11-14-2012, 04:44 PM
Rey Ocampo Re: Message Box if any of... 11-16-2012, 02:04 PM
AlphaFrog Re: Message Box if any of... 11-16-2012, 02:28 PM
Rey Ocampo Re: Message Box if any of... 11-16-2012, 02:42 PM
  1. #1
    Registered User
    Join Date
    06-22-2012
    Location
    Philippines, Pampanga
    MS-Off Ver
    Excel 2007
    Posts
    4

    Question Message Box if any of userform textbox are empty

    Hi, i am just starting to lear on how to use VB and i am wondering if you can help me in writting the correct code. I want a messagebox to show if any of the userform's textbox is empty or null. Submitter must fill all the details needed.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: Message Box if any of userform textbox are empty

    This is all the details needed IMHO.

        Dim ctl As Control
        For Each ctl In Me.Controls
            If TypeName(ctl) = "TextBox" Then
                If ctl = Empty Then
                    MsgBox "A text box is empty.", , "Missing Entry"
                    Exit For
                End If
            End If
        Next ctl

  3. #3
    Registered User
    Join Date
    06-22-2012
    Location
    Philippines, Pampanga
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Message Box if any of userform textbox are empty

    Thank you! I tried updating it in my form and unfotunately i dont know were to place my code:

    ActiveWorkbook.Sheets("VT Data").Activate
    Range("A1").Select
    Do
    If IsEmpty(ActiveCell) = False Then
    ActiveCell.Offset(1, 0).Select

    End If

    Loop Until IsEmpty(ActiveCell) = True
    ActiveCell.Value = TextRemedyID.Value
    ActiveCell.Offset(0, 13).Value = TextRequestor.Value
    ActiveCell.Offset(0, 12).Value = TextDateR.Value
    ActiveCell.Offset(0, 15).Value = TextDateR.Value
    ActiveCell.Offset(0, 11).Value = cmbTools.Value
    ActiveCell.Offset(0, 14).Value = TextRef.Value
    ActiveCell.Offset(0, 16).Value = CmbPOC.Value

    Unload Me
    ActiveWorkbook.Sheets("Voice Tracker").Activate
    Range("A1").Select

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: Message Box if any of userform textbox are empty

    Replace your above code with this...

        Dim ctl As Control
        
        For Each ctl In Me.Controls
            If TypeName(ctl) = "TextBox" Then
                If ctl = Empty Then
                    MsgBox "A text box is empty.", , "Missing Entry"
                    Exit Sub
                End If
            End If
        Next ctl
        
        With Sheets("VT Data").Range("A" & Rows.Count).End(xlUp)
            .Offset(1, 0).Value = TextRemedyID.Value
            .Offset(1, 13).Value = TextRequestor.Value
            .Offset(1, 12).Value = TextDateR.Value
            .Offset(1, 15).Value = TextDateR.Value
            .Offset(1, 11).Value = cmbTools.Value
            .Offset(1, 14).Value = TextRef.Value
            .Offset(1, 16).Value = CmbPOC.Value
        End With
        
        Application.Goto Sheets("Voice Tracker").Range("A1")
        Unload Me

  5. #5
    Registered User
    Join Date
    06-22-2012
    Location
    Philippines, Pampanga
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Message Box if any of userform textbox are empty

    Thank you!! Now its working..... Appreciate your Help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1