Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2004
    Posts
    5

    Talking Unanswered: Need help with syntax errors, can anyone help???

    Ihave tryed many different ways to get this to work biyt am still getting sytax errors.
    Can any find the problem or come up wiyj an alternitive?

    Private Sub addrecord_Click()
    On Error GoTo Err_addrecord_Click

    If Dcount ("[Reservation Date] = " & ReservationDate & " AND "[Asset ID] = " & AssetID & " AND " & TimeBookedIn & " BETWEEN [Time Booked Out] AND [Time Booked In] OR " & TimeBookedOut & " BETWEEN [Time Booked Out] AND [Time Booked In])") > 0 Then
    'MsgBox "Dulpicte Record, change asset ID or booking time"
    Else
    DoCmd.GoToRecord , , acNewRec


    End If




    Exit_addrecord_Click:
    Exit Sub

    Err_addrecord_Click:
    MsgBox Err.Description
    Resume Exit_addrecord_Click

    End Sub



    I want to prevent any double booking can any on help

    I am a beginner in access so go easy on me 

    For example:

    Customer 1 wants an asset from:
    Date: 11/11/04
    Time Booked Out14:00
    Time Booked In16:00

    Customer 2 wants to book the same asset from:
    Date: 11/11/04
    Time Booked Out 15:00
    Time Booked In 17:00

    The tables I have:

    Reservations
    Reservation ID
    Reservation Date
    Asset ID
    Booked Out
    Booked In
    Customer ID


    Asset
    Asset ID
    Asset Description
    Asset Photo

    Service Records
    Service Record ID
    Asset ID
    Description
    Problem Date
    Resolved Date

    Customers
    Customer ID
    Customer First Name
    Customer Last Name

    Assets
    Asset ID
    Time Collected
    Time Returned

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    if [Reservation Date] is a date, you need:
    If Dcount ("[Reservation Date] = #" & ReservationDate & "# AND...


    probably similarly for Time (but i dont use times so it's a guess)


    last thought, add some (many) parenthesis:

    ((this AND that) or theother) <> (this AND (that OR theother))

    without parenthesis to force A to think your way - murphy's law dictates that A will ALWAYS make the wrong guess.

    izy


    and finally i notice your abuse of DCOUNT() ...it is ghastly, sorry. think of it like
    DCOUNT("fieldInQuotes", "tableOrQueryInQuotes", "criteriaInQuotes")
    and you wont be suprised that yours doesn't work.

    izy
    Last edited by izyrider; 06-18-04 at 14:39.
    currently using SS 2008R2

Posting Permissions

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