Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Aweiher is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    25

    Compare records on continious form?

    I have a continuous form based on a query that is based on multiple tables, and has criteria that's based upon a control in the form (a date box). The form is a schedule of multiple employees, with appointment start and end times, and I would like it to prompt if an employee is double booked.



    So basically I need something like...
    if Previous Record.Technician = CurrentRecord.Technician then
    if Previous Record.End Time >Current Record.Start Time then
    msgbox"double booked something something"
    end if
    end if

    Is there is a syntax for doing something like this?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    use the query wizard to make a FIND DUPLICATEs query on that query.
    Only the doubles will show.

  3. #3
    Aweiher is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    25
    That won't work because the records aren't duplicated. For instance it might look like this...

    Employee Start Time End Time
    John Smith 8:00am 11:00am
    John Smith 9:30am 1:00pm

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,529
    See if this helps:

    http://www.baldyweb.com/OverLap.htm

    FYI, I deleted your duplicate thread.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Aweiher is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    25
    I can't really seem to translate the SQL in your link to a VBA code for my form. This seems so simple but I just can't get it. Referring to the "previous record" isn't as simple as it sounds.

    Also I cross posted because this is also a vba type question, maybe even more so than a Form question. Sorry. Maybe just move the thread?

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,529
    I'm not sure I would focus on "previous record", as you'd have to be sure the previous record was the only one that the new record could conflict with. I'd use an adaptation of that SQL to compare the new record against all records. You could have a saved query that used the new record in the criteria, and see if it returns any records.

    Most of the people who answer questions check all the forums, so I'm not real picky about which forum a question is in, as long as it's in the ballpark. I'll certainly move this one if you'd prefer.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Aweiher is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    25
    I tried your SQL, changing the related info. This is what I used
    SELECT tblSchedule.scInspector, tblSchedule.scStartTime, tblSchedule.scEndTime, tblSchedule.scDate
    FROM tblSchedule
    WHERE (((tblSchedule.[scStartTime])<=[Forms]![frmSchedule].[scEndTime]) AND ((tblSchedule.[scEndTime])>=[Forms]![frmSchedule].[scStartTime]) AND ((tblSchedule.scDate)=[forms]![frmSchedule]![txtGoToDay]));

    These were my results.
    Click image for larger version. 

Name:	SQL Results.png 
Views:	35 
Size:	6.1 KB 
ID:	23910


    This doesn't help at all. I don't think I'm conveying what I mean properly. Look at the attached picture of my form. See how Ed Day is scheduled to be in two places at once? I want that to alert the user when they try to close the form.
    Click image for larger version. 

Name:	Example Form.png 
Views:	34 
Size:	46.5 KB 
ID:	23911

    Thank you!

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,529
    You would have to account for the person as well. Can you attach the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I think we'd really need to know how your form is set up, if it's based on a crosstab query that's one thing
    if it's an unbound form that's another
    if it's a main form/subform arrangement that's yet another.

    That being said, pbaldy is steering you in the right direction, you don't want to check 1 record (either 'before' or 'after') you want to check against all records for that person on the same day to make sure there are no overlapping spans.

    Have you got a sample database we could take a look at?

  10. #10
    Aweiher is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    25
    I'm trying to add a copy but it's 112mb. I tried zipping it and that's not working either (it's just timing out). ugh..

  11. #11
    Aweiher is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    25
    Quote Originally Posted by rpeare View Post
    I think we'd really need to know how your form is set up, if it's based on a crosstab query that's one thing
    if it's an unbound form that's another
    if it's a main form/subform arrangement that's yet another.

    That being said, pbaldy is steering you in the right direction, you don't want to check 1 record (either 'before' or 'after') you want to check against all records for that person on the same day to make sure there are no overlapping spans.

    Have you got a sample database we could take a look at?
    It's a bound continuous form, with a crosstab subform in the Header. I'm only concerned with the Details section of the form, not the Crosstab portion. You might as well pretend there's no subform for the sake of the question.

  12. #12
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    you can make your database smaller by only importing the objects needed for this question into a different database and removing all but a sample of the data (leave enough sample data to replicate the problem) then compressing/zipping the file. We don't need the actual database just the portions that don't work the way you want along with any objects (queries, tables, reports, etc) necessary to make it run.

    I would think in the code running in the ON CLICK event of the 'add new appointment' button would be the perfect place to put the check to make sure the 'new' appointment is not overlapping any other appointments for the same person on the same day, basically a validation rule. This is why I prefer unbound forms because you can do this type of validation check prior to any data being added to your table.

  13. #13
    Aweiher is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    25
    I deleted everything that wasn't pertinent and compressed it and its still 3.36mb, which is too large (500k max). Can I email it?

  14. #14
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I'll send you a PM with my email address

  15. #15
    Aweiher is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    25
    ok repeare I just emailed it to you. Thanks and sorry for the slow response.

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

Similar Threads

  1. Replies: 9
    Last Post: 10-30-2014, 12:31 PM
  2. Replies: 1
    Last Post: 08-19-2011, 02:53 PM
  3. Compare Two types of records from one table
    By pstrahan in forum Access
    Replies: 1
    Last Post: 08-10-2011, 11:22 AM
  4. Access compare and sum records in two tables
    By piszczel in forum Queries
    Replies: 8
    Last Post: 05-23-2011, 02:07 AM
  5. Compare records in 2 tables
    By RalphJ in forum Access
    Replies: 13
    Last Post: 03-06-2011, 07:43 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