flag empty value in textbox

Important Notice


Please note that on 14th December 2023 users will experience an expected outage whilst we make upgrades to our network. We anticipate this process may take a couple of hours and so we apologise in advance for any inconvenience.

  • hello all
    im not that strong in writing vba codes , only know stuff from reading around here as spactator.


    i would like to get help as i need to creat a code in my userform that check if the opreator entering any value to text box other then 0 or blank . if he is trying to enter 0 or Blank it prevent from moving FW.


    textboxs is copying its profit multipliers values to a certain sheet in the workbook that reflacts the pricing per s\e after i press command button, this generating forcasting tables later on.


    so i must make sure that the end user wont be able to entere 0 or blank value for any textbox given


    thats my code so far:





    thanks guys

  • Re: flag empty value in textbox




    thanks,
    its partly helping me as i need to make sure numbers will be inserted.



    edit : found the same manual with numbers


    thank you very much

  • Re: flag empty value in textbox


    Glad you could fix your problem ...:wink:


    Thanks for your thanks ...:smile:

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Re: flag empty value in textbox


    hey , i dug deeper and found a very nice code (http://www.cpearson.com/excel/TextBox.htm)


    problem is that this code wont allow me to enter more then 1 digit and any digit after decimel


    i would like it to allow me enter up to: XXXXX.XX and blank is not allowed also , appriciate any help with it.


  • Re: flag empty value in textbox


    Hello again,


    You can test following...


    HTH

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Re: flag empty value in textbox


    thank you carim!
    only thing not resolved is that blank is acceptable
    there is any case that can be filled into the code that will prevent blank?
    or another procedureshould be added?

  • Re: flag empty value in textbox


    You are welcome ...


    Blanks should not be allowed with above code... have you tried to add blanks ???


    Otherwise, if you want to specifically exclude blanks, you can insert ...


    Code
    Case 32
      KeyAscii = 0


    HTH

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Re: flag empty value in textbox


    my problem is that my update button will change cells values according what entered inside the textboxes. thats only thing it will do


    i need a sulotion to prevent that update button to be active if any of the textboxs containing blanks


    code per textbox (there are 20-30 boxes):



    thats the code for the command button:


  • Re: flag empty value in textbox


    It would seem you have tackled a new issue ...no ???


    Have you sorted out the issue related to preventing users from adding spaces in their inputs ???

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Re: flag empty value in textbox


    Quote from Carim;786674

    It would seem you have tackled a new issue ...no ???


    Have you sorted out the issue related to preventing users from adding spaces in their inputs ???


    hey carim , that was never the issue, maybe i failed to explain myself better.


    My finale issue im dealing now is to "check" the textboxes to see that all of them have any value <0 (= No blanks in the textboxes) while im pressing command button that supposed to unload the form.


    "PrivateSub Updateb1_Click() "


    i made that command button unavaliable but i need a code that check all the boxes i have from TextBox43 to Textbox56 with value >0 then allow command button to be available to unload the form while during this action Cells updating with
    the values entered in the text boxes.

  • Re: flag empty value in textbox


    Hello,


    You could be testing the following ...


    Hope this will help

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Re: flag empty value in textbox


    carim thank you so much for helping me again.



    and got:


    [ATTACH=CONFIG]71553[/ATTACH]


    what im doing wrong?

  • Re: flag empty value in textbox


    Hello,


    The loop does the input after the check ... :wink:


    So ... as long as your Userform is called uf1 and your worksheet is called s1 ...


    the code should do the job ...


    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Re: flag empty value in textbox



    I revised the cmd button to that above.


    still getting that error


    [ATTACH=CONFIG]71554[/ATTACH][ATTACH=CONFIG]71555[/ATTACH]


    excuse me for my Noobiness

  • Re: flag empty value in textbox


    The trouble with attaching jpg pictures lies in the fact it does not provide an understanding of all the circumstances which might interfere ...


    Why don't you attach a sample workbook in your next post ...

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Re: flag empty value in textbox


    whish i could post my workbook i cant for confidentiality reasones


    any ways ,debugger indicates on the "****" line i marked :


  • Re: flag empty value in textbox


    This instruction


    If Len(Trim(ctl(i + 41).Value)) = 0 Then


    can bug
    - if the procedure is not located in the userform module
    - if the userform does not have a control named TextBox43 (i=2 + 41)


    You could test revised code ...



    HTH

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Re: flag empty value in textbox


    the revised code now wont give any debugger error but it put the computer into loop and eventualy allow the target cells here (s1.Cells(i, 6)) to change to blank or 0 incase all textboxes (43-56) are left blank or 0


  • Re: flag empty value in textbox


    You can always add more conditions ...


    HTH

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!