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

    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"
    DoCmd.GoToRecord , , acNewRec

    End If

    Exit Sub

    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:

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

    Asset ID
    Asset Description
    Asset Photo

    Service Records
    Service Record ID
    Asset ID
    Problem Date
    Resolved Date

    Customer ID
    Customer First Name
    Customer Last Name

    Asset ID
    Time Collected
    Time Returned

  2. #2
    Join Date
    Dec 2002
    Préverenges, Switzerland
    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.


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

    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