Results 1 to 14 of 14
  1. #1
    Soupy8728 is offline Novice
    Windows 11 Access 2016
    Join Date
    Mar 2024
    Posts
    13

    Structure for inventory with multiple allowances

    Hello,



    I am trying to build an inventory database and I'm running into an issue that I'm not sure how to approach. We have different locations and each location is allowed a certian amount of each item. In my example table below, Item A and Item B have fixed allowances of 10 and 15 respectively. The issue I'm having is Item C, D, and E have an allowance of 30 but it can be any combination of those items to make 30. How do I do this? Thank you for your time.


    tblINVENTORY

    ITEM ALLOWANCE
    ITEM A 10
    ITEM B 15
    ITEM C
    ITEM D
    ITEM E

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,526
    on the entry form , after every entry, lookup the limit


    Code:
    sub form_AfterUPdate()
    iEntryCount = Dcount("*","tEntryTbl","[item]='" & txtItem & "'")
    iLimit = Dlookup("[Allowance]","tblInventory","[item]='" & txtItem & "'")
    
    if iEntryCount > iLimit then
       msgbox "You are over the limit
    
        'delete record here?
    endif
    end sub

  3. #3
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,474
    So you are saying C,D,E can only have a combined limit of 30?

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,957
    I would write a function to do that.
    Function could have a Select Case
    For A & B just DLookup() as normal
    For anything else
    Process the recordsetclone and sum the amounts for C,D & E.
    I would not hard code the limit, but store them in a table in case they change.

    Then Dlookup() that limit, so C would be 30 atm and would count for C,D & E
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2019
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Quote Originally Posted by Soupy8728 View Post
    Hello,

    I am trying to build an inventory database and I'm running into an issue that I'm not sure how to approach. We have different locations and each location is allowed a certian amount of each item. In my example table below, Item A and Item B have fixed allowances of 10 and 15 respectively. The issue I'm having is Item C, D, and E have an allowance of 30 but it can be any combination of those items to make 30. How do I do this? Thank you for your time.


    tblINVENTORY

    ITEM ALLOWANCE
    ITEM A 10
    ITEM B 15
    ITEM C
    ITEM D
    ITEM E
    I think you may need to structure your tables differently. See attached
    Attached Files Attached Files
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  6. #6
    Soupy8728 is offline Novice
    Windows 11 Access 2016
    Join Date
    Mar 2024
    Posts
    13
    Yes, exactly. It could be 30 of C and 0 for D and E or 10 each....like that

  7. #7
    Soupy8728 is offline Novice
    Windows 11 Access 2016
    Join Date
    Mar 2024
    Posts
    13
    Quote Originally Posted by Bulzie View Post
    So you are saying C,D,E can only have a combined limit of 30?
    Yes, exactly. It could be 30 of C and 0 for D and E or 10 each....like that

  8. #8
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,432
    Is there some other factor you haven’t mentioned such as a shelf location? The location you mention could be anything from a shelf to a country

    think we need to better understand your business model to make some sort of sense of the requirement. Why can’t you have say 5 of item A and 5 each of C,D and E for example. Is the limits set based on weight or dimensions or some other factor? Are all locations the same spec? So any location can only have a max of 10 item A’s? Or could a different location hold 12 or 20 or 100?

  9. #9
    Soupy8728 is offline Novice
    Windows 11 Access 2016
    Join Date
    Mar 2024
    Posts
    13
    Quote Originally Posted by Bob Fitz View Post
    I think you may need to structure your tables differently. See attached
    Thanks Bob, that's what I was originally thinking but I just couldn't put it together in my head. This helps a lot!!

  10. #10
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2019
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Quote Originally Posted by Soupy8728 View Post
    Thanks Bob, that's what I was originally thinking but I just couldn't put it together in my head. This helps a lot!!
    Always glad to help, if I can. Post back if you have any questions about the db that I posted.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  11. #11
    Soupy8728 is offline Novice
    Windows 11 Access 2016
    Join Date
    Mar 2024
    Posts
    13
    Quote Originally Posted by Bob Fitz View Post
    Always glad to help, if I can. Post back if you have any questions about the db that I posted.
    Hello Bob, is there a macro in your database? I'm trying to open it at work but I get an error "macros in this document have been disabled by your enterprise administrator for security reasons". Thank you.

  12. #12
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2019
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Quote Originally Posted by Soupy8728 View Post
    Hello Bob, is there a macro in your database? I'm trying to open it at work but I get an error "macros in this document have been disabled by your enterprise administrator for security reasons". Thank you.
    No. I very seldom use macros. I prefer to use vba code which I have done in three event procedures in the form.
    I googled the error message and the results make me think that your problem is to do with the Trust Center. Perhaps you need to move the db to a "Trusted" folder.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  13. #13
    Soupy8728 is offline Novice
    Windows 11 Access 2016
    Join Date
    Mar 2024
    Posts
    13
    Quote Originally Posted by Bob Fitz View Post
    No. I very seldom use macros. I prefer to use vba code which I have done in three event procedures in the form.
    I googled the error message and the results make me think that your problem is to do with the Trust Center. Perhaps you need to move the db to a "Trusted" folder.
    Thank you. Appreciate your help!!

  14. #14
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2019
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Quote Originally Posted by Soupy8728 View Post
    Thank you. Appreciate your help!!
    You're welcome. Can you confirm my suspicions regarding the trust issue.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

Similar Threads

  1. need help in structure inventory DB
    By eugzl in forum Access
    Replies: 11
    Last Post: 12-05-2021, 05:30 AM
  2. Replies: 4
    Last Post: 12-30-2020, 11:55 AM
  3. Replies: 4
    Last Post: 08-21-2014, 12:16 PM
  4. Multiple options based on a tree structure...
    By blue22 in forum Database Design
    Replies: 3
    Last Post: 01-09-2014, 05:58 AM
  5. Query to find telephone allowances
    By gofbang in forum Queries
    Replies: 0
    Last Post: 12-19-2010, 02:02 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