+ Reply to Thread
Results 1 to 3 of 3

Not adding information if fields are missing

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Crayford, kent
    MS-Off Ver
    Excel 2013
    Posts
    394

    Not adding information if fields are missing

    I have set a msgbox to display a warning if fields are missing, and i thought the code that i have in here would stop the data being inputted into the worksheet.

    But.... It doesnt it still adds the data even if some fields are missing, what have i done wrong here? and what do i need to do to correct it?

    '//Check for all required entries
    If category.Value = "" Or customer.Value = "" Or category.Value = "Select" Or customer.Value = "Select" Or product.Value = "" Or product.Value = "Select" Or salespart.Value = "" Or salespart.Value = "Select" Or purchaseprice.Value = "" Or purchaseprice.Value = "Enter Price Here" Or casesin.Value = "Enter Value Here" Or casesin.Value = "" Or casesout.Value = "Enter Value Here" Or casesout.Value = "" Or salesprice = "" Or salesprice = "Enter Price Here" Or hemisphere.Value = "" Or Origin.Value = "" Or site.Value = "" Or supplier.Value = "" Or packagingtype.Value = "" Or ordertype.Value = "" Or cratesize.Value = "" Then
    
    '//Notify user if entries are missing
    MsgBox "Some Fields Are Missing, Please Check And Fill In Missing Entries", vbOKOnly + vbExclamation, "Warning! Input Error"
    
    
    Dim cCtrl As Control
         
        For Each cCtrl In Me.Controls
            If cCtrl.Tag = "Must" Then
                Select Case TypeName(cCtrl)
                Case "TextBox"
                    If cCtrl = vbNullString Then
                        MsgBox cCtrl.Name & " is mandatory"
                        cCtrl.SetFocus
                        Exit Sub
                    End If
                Case Else
                     'Whatver
                End Select
            End If
        Next cCtrl
        
    End If

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Not adding information if fields are missing

    Is this solved?

    If you solve a problem yourself before anyone else has responded, please take a moment to describe your solution, chances are some other member will benefit.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Crayford, kent
    MS-Off Ver
    Excel 2013
    Posts
    394

    Re: Not adding information if fields are missing

    Hi Sorry

    Yes all i done was added exit sub directly before the end if at the end of this code, at it worked

+ 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