Results 1 to 5 of 5
  1. #1
    Deutz is offline Advanced Beginner
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Oct 2010
    Posts
    51

    Validate on sum of multipule textboxes

    Hi and thanks in advance.



    I'm using Access 2003 and have three textboxes formatted to percent with zero decimal places.

    I am wondering if it's possible to validate each textbox as the user enters a figure, ensuring the total percent (all the three textboxes summed) does not exceed 100 percent?

    I suppose I could do the validation on saving but as I will have quite a number of these scenarios in database, I thought it would be better to validate at the time the user enters the data, if possible.

    Thanks
    Michael

  2. #2
    Rixxe is offline Blessed Bear
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Location
    London (Essex ... yep!)
    Posts
    184
    Hi, I cannot help you write the code, but i found a link or 2 on validation using VB:

    http://forums.aspfree.com/visual-bas...ion-21712.html
    http://www.ozgrid.com/VBA/validate-numbers.htm

    There's actually loads out there, my suggestion would be to take the basic code, and adapt it based on what you need and come back once you have something which just needs tweeking.

    Good Luck

  3. #3
    Deutz is offline Advanced Beginner
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Oct 2010
    Posts
    51
    Thanks for your answer Rixxie,

    However, the info in your links doesn't really answer my question as I'm trying to validate what's being entered into a textbox based on the sum of: (the value being entered and the values existing in two other textboxes) ... must all add up to <= 100%

  4. #4
    Rixxe is offline Blessed Bear
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Location
    London (Essex ... yep!)
    Posts
    184
    The idea is similar, for example:

    int ThatNumber = 100;

    If (textBoxA.Text + textBoxB.Text + TextboxC.Text == ThatNumber)
    {
    Allow it to perform the task
    }
    else
    {
    Error Message, and wipe the text boxes or something
    }

    Obviously its not even close to the correct syntax, but it should be possible to do something similar just fiddeling around with it.
    It easy to say 'If textbox = something, do this' So it shouldnt be that difficult with the syntax from the links posted.
    If however you want someone to write it for you, then hopefully they will answer and help you out

    Good Luck.

  5. #5
    Deutz is offline Advanced Beginner
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Oct 2010
    Posts
    51
    Thanks Rixxie,

    You example was helpful. The problem I had was due to formatting the textboxes as percent so that when I added them together I was not getting the right result. I came up with this validation rule which now works: Is Null Or (>0 And (nz([TextBox1)+nz([Textbox2])*100+nz([TextBox3])*100)<=100).

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Hide textboxes only on new record.
    By SRSA in forum Programming
    Replies: 2
    Last Post: 02-28-2011, 04:31 PM
  2. Module to be run by macro to validate
    By GraemeG in forum Modules
    Replies: 4
    Last Post: 02-26-2011, 06:26 AM
  3. #Name? errors with textboxes
    By jasonbarnes in forum Forms
    Replies: 3
    Last Post: 12-16-2010, 09:51 AM
  4. Creating Multipule records
    By Icewolf0927 in forum Queries
    Replies: 3
    Last Post: 10-27-2010, 02:03 PM
  5. Drag and Drop Between Textboxes. Please Help!
    By kcpope in forum Programming
    Replies: 2
    Last Post: 10-19-2010, 05:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums