+ Reply to Thread
Results 1 to 6 of 6

Code error in blank text boxes checking and saving in user form

  1. #1
    Registered User
    Join Date
    11-29-2010
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    17

    Code error in blank text boxes checking and saving in user form

    Dear Members,

    I am using user form to collect data and save to worksheet.

    Following error is coming:

    a) My vba Code not checking entire blank text boxes

    b) When any textbox is having data, code stopping there, even blank text boxes present after that data textbox, code is not checking that part

    Example:

    i) If first textbox in user form having data, my code is stopping there, even if next textbox is blank, it is not checking that part

    ii) Code is executing until it founds, data in textbox, if it found data in a text box, it is stopping there, not going further text boxes


    c) Before saving user form, it is not checking entire user form for blank text boxes. It is only checking first text box, if it is blank otherwise

    d) If first text box is having data, code not checking any blank text boxes and saving the data


    Any help in this regard is greatly appreciated

    Thank you
    Jwala

    I am uploading the file for your reference


    Using the following vba code:


    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by jwala; 12-03-2010 at 08:18 AM.

  2. #2
    Forum Contributor
    Join Date
    07-05-2006
    Location
    Canada
    MS-Off Ver
    2003, 2007
    Posts
    581

    Re: Code error in blank text boxes checking and saving in user form

    Hi,

    The reason you're having the issue is how you've set up your IF statements. The following Code segment contains your IF statements (I removed some of the text to remove clutter, since it's the IF statement layout I'm trying to emphasize):

    Please Login or Register  to view this content.


    When your first IF statement is FALSE -- that is,
    Trim(Me.txcustname.Value) <> "" -- then all the rest of the inner code doesn't get executed. That's how nested IF statements work (which is what you're doing)

    At the end of your if statements, you have a whole bunch of End Ifs, one for each of your preceeding IF statements.

    The layout I'd recommend is this (note the End Ifs are in different places):

    Please Login or Register  to view this content.

    S
    Last edited by Maistrye; 12-03-2010 at 01:44 AM.
    ------------------------------------------------------------------------------------------
    If you need no more help on the current problem, please mark it as "Solved". It saves time
    as many of us will look at threads if they are not marked as "Solved".

    The instructions on how to do this are found in the Forum Rules thread that is at top of every forum.
    (Currently you'll have to look at point #9.)
    ------------------------------------------------------------------------------------------

  3. #3
    Registered User
    Join Date
    11-29-2010
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Code error in blank text boxes checking and saving in user form

    Dear Maistrye,

    I thank you very much for your valuable time, your suggestion solved my problem

    Regards
    Jwala

  4. #4
    Registered User
    Join Date
    11-29-2010
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Code error in blank text boxes checking and saving in user form

    Dear Members,

    How to tag my question has (SOLVED)

    SO, NO ONE WASTE THEIR TIME ON ALREADY SOLVED PROBLEM

    Regards
    jwala

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Code error in blank text boxes checking and saving in user form

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Registered User
    Join Date
    11-29-2010
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Code error in blank text boxes checking and saving in user form

    Dear Royuk

    Thank you for your valuable time

    Regards
    jwala

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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