+ Reply to Thread
Results 1 to 10 of 10

Blank cells added to database

  1. #1
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Blank cells added to database

    I have the following code which updates a database. I would like to ensure that when the user hits the SUBMIT button they are not accidentally adding blank information to the database. Basically, if there is no name entered, I would like the user to receive an error and not be permitted to add empty values to the database.


    Please Login or Register  to view this content.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,864

    Re: Blank cells added to database

    may be:

    Please Login or Register  to view this content.
    Best Regards,

    Kaper

  3. #3
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Blank cells added to database

    I tried it. It did give me the pop-up box, but it still added an empty row on the DATABASE sheet

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Blank cells added to database

    Hello tapsmiled,

    This will display a message to the user then exit the macro leaving the Text Boxes as they were.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,864

    Re: Blank cells added to database

    Hi tapsmiled,

    Can't be true.
    If condition is met, only msgbox pops out and then everything between else and end if is skipped.

  6. #6
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Blank cells added to database

    Quote Originally Posted by Leith Ross View Post
    Hello tapsmiled,

    This will display a message to the user then exit the macro leaving the Text Boxes as they were.

    Please Login or Register  to view this content.


    Worked perfectly. Thank you!!!

  7. #7
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Blank cells added to database

    Quote Originally Posted by Kaper View Post
    Hi tapsmiled,

    Can't be true.
    If condition is met, only msgbox pops out and then everything between else and end if is skipped.
    Somehow it only populated the comma that appears between Last Name and First Name. I did get it to work, though, with the above formula. Thank you anyway for your assistance!!

  8. #8
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,864

    Re: Blank cells added to database

    OK. Let me dig a bit deeper, because I love to learn from such cases. The longer I deal with it, the more obvious to me is that I am still on the steep part of Excel (and especially VBA) learning curve.

    In my eyes, the only difference is that:
    Please Login or Register  to view this content.
    checks only firstname and lastname for beeing empty
    while
    Please Login or Register  to view this content.
    checks if any of: lastname, firstname, CCN and date of hire is empty (has len=0)

    the rest, I mean this:
    Please Login or Register  to view this content.
    and this:

    Please Login or Register  to view this content.
    are equivalent.

    So if someone (Leith Ross?) could explain why one works and other not, I'd appreciate.

    Of course, I'm glad that at least one suggestion helped with the main problem of the thread.

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Blank cells added to database

    Hello Kaper,

    In the future, please do not post a new question in existing thread . Please start a new thread and include the URL or a link to the post you have a question about.

    Please Login or Register  to view this content.
    The code above validates that first name and last name are not empty (zero length strings) and they are not just spaces. The Trim function removes leading and trailing spaces from the string.

    Which one is not working for you?

  10. #10
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,864

    Re: Blank cells added to database

    For me both solutions work. But for tapsmiled mine did not, because (thanks for explaining this) the textbox(es) was(ere) not really empty but contained for instance a space (still looked as blank ones).

    Probably this observation:
    It did give me the pop-up box
    was for one case (really empty) and this:
    but it still added an empty row
    for (not really empty - just looking empty).
    Last edited by Kaper; 03-05-2014 at 03:27 PM.

+ 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] Formula to keep adjacent cell blank when no date is added!
    By Antligen in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-23-2014, 01:58 PM
  2. [SOLVED] Want the cells with the formulas to appear blank until conditions are added
    By Kattracks in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-01-2013, 12:07 PM
  3. [SOLVED] Blank Cells Getting Added
    By dadrew in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 09-11-2012, 03:01 PM
  4. Replies: 3
    Last Post: 11-07-2005, 11:15 PM
  5. [SOLVED] Making sure that cells within a row in a database aren't blank
    By Pete Rooney in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-06-2005, 03:05 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