+ Reply to Thread
Results 1 to 13 of 13

Prevent double booking by unique serial and dates

  1. #1
    Registered User
    Join Date
    06-25-2014
    Location
    Denmark
    MS-Off Ver
    365 (Win and Mac)
    Posts
    20

    Prevent double booking by unique serial and dates

    Hey you all..!!

    I am working on a little booking system (equipment rental) and I have figured out have to match double bookings by serial in column "B", but I want the form to find the serial and check for available dates.
    Like this NOT A CODE (Check out the pictures and code if you don't understand)

    Find match (Serial) = True then
    IF End date (Second TexBox (2) in form) > Column "E" Start Date (and row where it did match the Serial) = True then
    MsgBox "There is already a booking in this in selected period"

    IF not true then
    IF Start Date (First TextBox (1) in form) < Column "F" End Date (and row where it did match the Serial) = True then
    MsgBox "There is already a booking in this in selected period"

    Thanks in advance, let me know if you need more information.

    BookForm.JPG

    DataBase.JPG

    This is what I have so far

    Please Login or Register  to view this content.
    And here is the full code if your are interested

    Please Login or Register  to view this content.

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Prevent double booking by unique serial and dates

    we need a workbook to work something for you. Can you attach one?
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

  3. #3
    Registered User
    Join Date
    06-25-2014
    Location
    Denmark
    MS-Off Ver
    365 (Win and Mac)
    Posts
    20

    Re: Prevent double booking by unique serial and dates

    Hey p24leclerc.

    Thank you for your time, I've have attached a sample of my workbook.

    Booking_System_Sample.xlsm

  4. #4
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Prevent double booking by unique serial and dates

    I did some modification to your Book macro. Please look at it and tell me if it looks like I'm on the right way.
    The way you look for the serial (which is in column E by the way) you only find the first one. Is it that you can only have one occurence of a serial in this table. If not, then you ought to look for all occurences and test for the start and end date before booking.
    As I can't read Danish, I'm not sure I'm doing the right thing but I think I'm not so far. Am I?

  5. #5
    Registered User
    Join Date
    06-25-2014
    Location
    Denmark
    MS-Off Ver
    365 (Win and Mac)
    Posts
    20

    Re: Prevent double booking by unique serial and dates

    Can't see anything attached..
    You are right with the Serial, it should look for more occurences, because the equipment could be booked more then one with different dates..

  6. #6
    Registered User
    Join Date
    06-25-2014
    Location
    Denmark
    MS-Off Ver
    365 (Win and Mac)
    Posts
    20

    Re: Prevent double booking by unique serial and dates

    And yes the column I have change, I Just forgot to change it in the book form before uploading sorry..

  7. #7
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Prevent double booking by unique serial and dates

    Oops! here is the file. It actually searches only the first occurence. Lets see first if I'm working in the right direction.
    Regards
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    06-25-2014
    Location
    Denmark
    MS-Off Ver
    365 (Win and Mac)
    Posts
    20

    Re: Prevent double booking by unique serial and dates

    Hey p24leclerc.

    Know I tried the code, it gives good logic, but I can't get it to work. So I tried specify the sheet but it did't work neither.
    When I book something in the same period as another it just says "Your equipment is book" and nothing happens.

    Maybe it has something to do with the date values, I can't figure out if it reading it right, because the dates in the table are converted to text by CDate when they are pasted in. So maybe there is a clash with dates, but I don't. But the Num is picking up the line of the Serial fine. Oh and if i book stuff after the end date it works as normal. I will try some looking around for date properties if it is the problem.

    But thank I think it gives good sense though.

    Please Login or Register  to view this content.

  9. #9
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Prevent double booking by unique serial and dates

    Strange as it is working onmy computer.
    Lets try this new workbook.
    I changed the IF statement using DATESERIAL to compare dates which should not be sensitive to the system configuration.
    It can always be a problem when working with dates.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    06-25-2014
    Location
    Denmark
    MS-Off Ver
    365 (Win and Mac)
    Posts
    20

    Re: Prevent double booking by unique serial and dates

    That is cool. Okay it is working now when I book inside another booked period, but if I choose a date later then the end date it stills says "Equipment booked" and nothing is put in the table. Funny. Hey this is great now I have something to work with and I can see that it is possible.
    Do you know if it is possible to put the date checking inside a variable? Like Check1 = If DateSerial(Year(Trim(txtSlutUdstyr.Value)), Month(Trim(txtSlutUdstyr.Value)), Day(Trim(txtSlutUdstyr.Value))) > DateSerial(Year.....

    and then if
    Check1 = True
    MsgBox "Equipment booked"

    Check1 = False
    Continue to Check2 and so on

    Because what I can see that I need to check the start date as well and then the code gets very big and hard to keep track on.

    And one last question (Sorry for the noob stuff) To check for more occurrences for the serial I need to create a loop right? I have tried to work with a loop before, I "made" a search through a UserForm to collect data from a big database, but it did't really work and excel crashed from time to time. So if you are good with loops could you teach me how to do this?

    I really appreciate the stuff you already have done, so thanks!

  11. #11
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Prevent double booking by unique serial and dates

    Yes, we can put that in a variable. I'll look into this tomorrow.

    Can you tell me what are all the tests you want to do with those dates?
    What are the conditions to allow to book an item?

    I'll also look into the loop issue tomorrow.
    Regards

  12. #12
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Prevent double booking by unique serial and dates

    Try the attached workbook.
    I think I was able to set up the date's constraints to prevent double booking along with the loop to search the whole table.
    Let me know how it works for you.
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    06-25-2014
    Location
    Denmark
    MS-Off Ver
    365 (Win and Mac)
    Posts
    20

    Re: Prevent double booking by unique serial and dates

    Wow.!!! You nailed it..!! Thank you so much... You've done it all right with the checking of dates and nice with the variables as well..

    When I am done with this book I will send it to you..

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Comparing postcodes and booking dates to identify clashes
    By ScottishJacqui in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-03-2014, 11:52 AM
  2. double reservation in a Excel booking system
    By Janoz in forum Excel General
    Replies: 3
    Last Post: 11-05-2013, 10:00 PM
  3. [SOLVED] Prevent a month from appearing as a serial number
    By Scott_88 in forum Excel General
    Replies: 3
    Last Post: 11-02-2012, 07:42 AM
  4. [SOLVED] Prevent Clng from dropping Time off returned Serial value
    By bdb1974 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-27-2012, 04:44 PM
  5. Serial dates in VBA vs Serial dates in Excel
    By tom.hogan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-20-2011, 09:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1