Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Lily21 is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    May 2021
    Location
    Canada, Montreal
    Posts
    21

    Make an item of equipment unavailable in a list when it is selected on a date

    Hello,
    I'd like to know if there is a way to block the user from choosing a equipment from a drop-down list if it has already been selected at a date range.



    So I have a form where the user can choose an equipment and a start and end date for its use. So I would like the equipment to no longer be available in the list if we choose another date that falls within the date range when the equipment is already picked up.

    Ps: I'm really not comfortable with VBA

    thanks a lot for your help

  2. #2
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    What is the structure of your tables / data?
    This could be quite simple or complicated depending on your tables and the relationships?

    Do you have a list of equipment and a separate table of equipment rentals?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,421
    Afraid you'll need to prepare yourself for some discomfort.
    We need to know more about your table structure, showing how an equipment is already selected, and how the form appears to the user making selections.
    Best way if for you to upload your DB here for analysis.

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,818
    I think you would have to filter the combo list with a query or sql that checks if the user entered date falls between any start and end date for that equipment. You could build and test this query and verify it works correctly before setting the combo row source to that query. There might be other options, such as a subform showing the in/out dates for the chosen equipment. Then users could see what's available at a glance.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Lily21 is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    May 2021
    Location
    Canada, Montreal
    Posts
    21
    Hi,
    Heres my base, I put pictures of the tables who are related to what I want to do (sorry its in french)

    Équipement = the table of equipment (id, name of the equipment)
    Réservation_équipement = the table related with the équipement table (id, id_equipment, start date of reservation, end date of reservation)


    And ''créer_projet'' its the table and the form ''créer_projet Form'' where the user can entry the dates and the equipments and others stuff that it dont impact anything in what I want to do.


    Thank you for helping me
    Attached Files Attached Files

  6. #6
    Lily21 is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    May 2021
    Location
    Canada, Montreal
    Posts
    21
    Hi,
    I put my DB down for analysis
    Thank you

  7. #7
    Lily21 is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    May 2021
    Location
    Canada, Montreal
    Posts
    21
    Quote Originally Posted by Minty View Post
    What is the structure of your tables / data?
    This could be quite simple or complicated depending on your tables and the relationships?

    Do you have a list of equipment and a separate table of equipment rentals?
    Yes I have something like that, I put my DB down below if you can look at the structure, I dont know if I need to change something in the structure to make it more easier.

  8. #8
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,421
    Main table has 2 multivalue fields holding the reserved equipment and the startdate-enddate all in the same record.
    Making comparisons against that structure for new reservation conflicts would be monumental task, i.e. comparing items in a multivalue field versus items in another multivalue field involving 2 date ranges.
    Have a look at this: Multivalued Fields - Mendip Data Systems

  9. #9
    Lily21 is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    May 2021
    Location
    Canada, Montreal
    Posts
    21
    How I can do differently? Because I really need that the user can choose more than 1 equipment

  10. #10
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,421
    You need to set up a main table, the projects, and a child table to hold reserved equipment. The child table would hold ONE piece of equipment in each record.
    Your current structure is complicated by having equipment in two tables. Much simpler to combine into one table.

  11. #11
    Lily21 is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    May 2021
    Location
    Canada, Montreal
    Posts
    21
    Quote Originally Posted by davegri View Post
    You need to set up a main table, the projects, and a child table to hold reserved equipment. The child table would hold ONE piece of equipment in each record.
    Your current structure is complicated by having equipment in two tables. Much simpler to combine into one table.

    I'm lost
    My main table is = créer_projet
    My child table ? : do I need to keep equipment table or reserved equipment ? witch one I need to delete ?


    If I understand I have to put in my équipement table the field name that I put in my Reservation table ? so I can delete the reservation table?
    So my child table will be : Équipement (id,name,start date reservation, end date reservation)

  12. #12
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,421
    I think creer_project would be the child table, with Projet being the main table. Some fields in creer_Project should be moved to Project.
    The table lookups should be removed from creer_project. Those lookups should be done from the form's comboboxes.
    I can't respond again until this afternoon, as prior plans interfere.

  13. #13
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,818
    Well, it should be possible to come up with something or else there'd be absolutely no point in anyone using mvf or nothing would ever work for anyone. If the form is open and on a record that has values in both date fields, this would return a record matching the record on the form:
    Code:
    SELECT Créer_Projet.Id, Créer_Projet.[Chef_d'équipe].Value, Créer_Projet.Date_Début, Créer_Projet.Date_Fin
    FROM Créer_Projet
    WHERE (((Date_Début)>=Forms![Créer_Projet Form].Date_Début) AND ((Date_Fin)<=Forms![Créer_Projet Form].Date_Fin));
    So if DLookup in code returned a record, then it is loaned out. Not saying the db should not be re-designed, just saying it's quite possible to work with mv fields. Such queries need to use the .Value property of a mvf.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  14. #14
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,421
    Perhaps Micron is on the right track. I've never worked with MVFs, so if his approach is workable, it appears to be much simpler than redesigning the DB.

  15. #15
    Lily21 is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    May 2021
    Location
    Canada, Montreal
    Posts
    21
    Thank you so much this query work and it is perfect for what I want to do.
    But what I can do so that the user can not choose the equipment that the query return?

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 12-02-2020, 07:35 AM
  2. Replies: 3
    Last Post: 08-13-2020, 02:47 PM
  3. Identify the first selected item from a list box
    By jcc285 in forum Programming
    Replies: 5
    Last Post: 04-29-2020, 12:18 PM
  4. Change Font Color of Selected List Box Item
    By buckwheat in forum Access
    Replies: 2
    Last Post: 06-03-2013, 03:46 PM
  5. Replies: 4
    Last Post: 07-27-2011, 09:52 AM

Tags for this Thread

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