Results 1 to 8 of 8
  1. #1
    Georgi is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2012
    Posts
    17

    VBA code stop adding value when textbox exceed 50

    Good day to all,

    I have built a database somewhere I need to create a button to add (1) more item to the text box but the number in that text box should not exceed (50) and also note that the text box should be locked to prevent manually changing data. Is there any VBA code to stop adding values to the text box whenever the number reaches 50?

    Please see attached file.



    Thank you in advance and have a great day.
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    You are adding multiple (up to 50!!) distinct values in a single field? This is extremely bad db design. Recommend you NOT do this.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    The OP is talking about increasing a quantity by 1 each time the Command Button is clicked, but limiting it to 50.

    Change your OnClick code to

    Code:
    Private Sub Command1_Click()
     If Me.Quantity < 50 Then
       Me.Quantity = Me.Quantity + 1
     End If
    End Sub

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Georgi is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2012
    Posts
    17
    Quote Originally Posted by Missinglinq View Post
    The OP is talking about increasing a quantity by 1 each time the Command Button is clicked, but limiting it to 50.

    Change your OnClick code to

    Code:
    Private Sub Command1_Click()
     If Me.Quantity < 50 Then
       Me.Quantity = Me.Quantity + 1
     End If
    End Sub

    Linq ;0)>
    Good day, thank you very much it works now I appreciate that,

    Please see attached picture how the database looks like,

    Have a great day,
    Georgi
    Attached Thumbnails Attached Thumbnails Picture1.jpg  

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    And when I re-read OP it is so obvious! Must have been half asleep. Glad Linq got you on the right track.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    Georgi is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2012
    Posts
    17
    Hi Guys, one more question:
    How can I classify this post as resolved?
    Thank you in advance,
    Georgi

  7. #7
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  8. #8
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad we could help!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Adding Textbox value into Table
    By sikhinvestor in forum Access
    Replies: 2
    Last Post: 06-05-2014, 07:29 AM
  2. If New Record Stop Code Exit Sub
    By burrina in forum Forms
    Replies: 1
    Last Post: 12-19-2012, 01:02 PM
  3. How Can I Exceed 255 Fields in a Table?
    By JayKe in forum Access
    Replies: 3
    Last Post: 10-21-2012, 04:38 AM
  4. Navigation Buttons Stop My Code
    By millerdav99 in forum Programming
    Replies: 6
    Last Post: 03-18-2011, 11:13 AM
  5. stop access from auto adding records
    By svcghost in forum Forms
    Replies: 2
    Last Post: 10-21-2010, 05:25 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