Results 1 to 5 of 5
  1. #1
    Summit_IT is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Location
    Virginia
    Posts
    47

    CODE TO : Limit "qty" field in form to "1" when a part has a serial number


    I have a form containing a list of parts contained in an assembly. Some of those parts are serialized. My form now allows me to enter any number in the quantity field and only one serial number. I want the code to show the user "You can only have a quantity of 1 for a serialized part. Please change quantity to 1"

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Possibly on the AfterUpdate event of the serial control
    Code:
    If Len(Me.txtSerial.Text) <> 0 And Me.txtQty > 1 Then
     Msgbox "You can only have a quantity of 1 for a serialized part. Please change quantity  to 1"
     Me.txtQty.SetFocus
    End If
    I chose Len and Text because it will deal with when user removes what's in the serial number control whereas I don't think other tests would - especially testing on Value.
    I'm assuming the form is bound as well as other things. You didn't provide much info about it. One other thing - possibly the event should be handled at the form level, otherwise the user could simply proceed with a serial and qty> 1. In that case, code would be needed in the form's BeforeUpdate event and any action that was going to save this record would be Canceled.
    Last edited by Micron; 11-14-2019 at 08:42 AM. Reason: code correction
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Summit_IT is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Location
    Virginia
    Posts
    47
    I'll try that,
    Thanks

  4. #4
    Summit_IT is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Location
    Virginia
    Posts
    47
    Thanks Micron
    That works for me.

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    which event did you use? care to post the code?
    You could mark this solved if done.

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

Similar Threads

  1. Simple table relationships ("faces" to "spaces" to "chairs")
    By skydivetom in forum Database Design
    Replies: 36
    Last Post: 07-20-2019, 01:49 PM
  2. Replies: 4
    Last Post: 04-26-2019, 10:57 AM
  3. Replies: 2
    Last Post: 12-23-2015, 09:32 PM
  4. Replies: 1
    Last Post: 09-07-2015, 08:00 AM
  5. Replies: 16
    Last Post: 07-22-2011, 09:23 AM

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