+ Reply to Thread
Results 1 to 3 of 3

UserForm Validation - Check Text and Combo Boxes have entries before saving.

Hybrid View

  1. #1
    Registered User
    Join Date
    05-20-2015
    Location
    Derbyshire
    MS-Off Ver
    2013
    Posts
    2

    Arrow UserForm Validation - Check Text and Combo Boxes have entries before saving.

    Hello All,

    Im a noob when it comes to VBA userforms and I'm going around in circles with this problem. I have put together this code that checks if a .Tag caption has "MUST" in it then checks to see if the text or combo boxes have entries in and if the don't a MsgBox pops up and says you have missed X please fill it out. It kind of works as it does check the text and comboBoxs but in a random order (Middle - Top - Bottom ) - so my question is... is there a way to get it to check from the 1st box on the form and then step through them in order?

    The workbook, userform and code are attached. code below.

    Thanks in advance.

    Private Sub SaveButton_Click()
    'Writing to the databases
    
    'After you have entered details in to the form this writes to the database
    
    Dim emptyRow As Long
      Dim cCont As Control
      
         'FILL ALL MANDATORY CONTROLS TAG  PROPERTIES WITH "MUST"
        For Each cCont In Me.Controls
            If UCase(cCont.Tag) = "MUST" Then
                If cCont = vbNullString Then
                    MsgBox "Missing Data in " & cCont.Name
                    cCont.SetFocus
                    Exit Sub
                  End If
            End If
        Next cCont
           
        
    'Make Sheet active
    Sheet8.Activate
    
    'Determine emptyRow
    emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
    
    'Transfer information
    Cells(emptyRow, 1).Value = YearComboBox.Value
    Cells(emptyRow, 2).Value = CompanyComboBox.Value
    Cells(emptyRow, 3).Value = SiteComboBox.Value
    Cells(emptyRow, 4).Value = TestTypeL1ComboBox.Value
    Cells(emptyRow, 5).Value = TestTypeL2ComboBox.Value
    Cells(emptyRow, 6).Value = TestTypeL3ComboBox.Value
    Cells(emptyRow, 7).Value = TotSamplesTextBox.Value
    Cells(emptyRow, 8).Value = Results1TextBox.Value
    Cells(emptyRow, 9).Value = Results2TextBox.Value
    Cells(emptyRow, 10).Value = Results3TextBox.Value
        
    End Sub
    Attached Files Attached Files
    Last edited by Barny505; 05-21-2015 at 05:51 AM. Reason: Sorry missed that step

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: UserForm Validation - Check Text and Combo Boxes have entries before saving.

    Welcome to the forum! When you joined recently you agreed to abide by the Forum Rules, but in haste I fear you might not have actually read them. Please stop and take a moment to read them now. We all follow these rules for the benefit of all, as must you. Thanks.

    (link above in the menu bar)

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

  3. #3
    Registered User
    Join Date
    05-20-2015
    Location
    Derbyshire
    MS-Off Ver
    2013
    Posts
    2

    Re: UserForm Validation - Check Text and Combo Boxes have entries before saving.

    Hi, Thanks for that - All sorted now I hope.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Userform with dynamic Combo boxes and text box fill
    By Raylou in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 11-18-2014, 08:39 AM
  2. Userform with dynamic Combo boxes and text box fill
    By Raylou in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-04-2014, 01:02 AM
  3. [SOLVED] Clear all text boxes-combo boxes in a userform.
    By MariaPap in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-31-2014, 11:16 AM
  4. [SOLVED] Help with code for userform text boxes, combo boxes and excel
    By innerise in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-20-2014, 09:07 AM
  5. I need a code for presence check to check multiple text boxes and combo boxes
    By Lee_wwfc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-24-2013, 01:53 PM

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