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

    Unhappy Unanswered: Now having problems getting code to work in access

    I Have a save button on the form the reservations form and when the user clicks save it checks for availability. I have included some information at the bottom that may help you to help me??.

    I put it behind the OnClik, in the VB code Window, the message comes back with a syntax error. I am really stupid I know but could you please help??


    Sub save_Click()
    On Error GoTo Err_save_Click

    If DCount("[Reservation ID]", "Reservations", "[Reservation Date] = " & someDate & " AND [asset ID] = " & AssetID & " AND " & someTimeIn & " BETWEEN [Time Booked Out] AND [Time Booked In] OR " & someTimeOut & " BETWEEN [Time Booked Out] AND [Time Booked In]") > 0 Then
    'asset booked code
    Else
    'asset available code
    End If

    Exit_save_Click:
    Exit Sub

    Err_save_Click:


    MsgBox Err.Description
    Resume Exit_save_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

    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
    Address
    Postcode
    Reservations
    Reservation ID
    Customer ID
    Reservation Date
    Booked Out
    Booked In
    Asset ID
    Viewer Window
    Asset ID
    Time Collected
    Time Returned
    Last edited by shanehowe; 06-17-04 at 09:05.

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Here's one suggestion, you'll probably need to tweek it a bit:

    If DCount("[Reservation ID]", "Reservations", "[Reservation Date] = " & someDate & " AND "( & someTimeIn & " BETWEEN [Time Booked Out] AND [Time Booked In] OR " & someTimeOut & " BETWEEN [Time Booked Out] AND [Time Booked In])") > 0 Then
    'asset booked code
    Else
    'asset available code
    End If


    btw: your asset ID isn't linked to anything, you may want to look at that.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Jun 2004
    Posts
    5

    Thumbs up

    btw: your asset ID isn't linked to anything, you may want to look at that.[/QUOTE]

    i have now got the asset id relating to reservations, would that chage anything in your code??

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Yup, you would need to add a " AND [asset ID] = " & assetID
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  5. #5
    Join Date
    Jun 2004
    Posts
    5

    Thumbs up

    chears i will give that ago

  6. #6
    Join Date
    Jun 2004
    Posts
    5

    Question Still having problems

    I Have a save button on the form window so I have tried to place it there.

    I put it behind the OnClik, in the VB code Window, the message comes back with a syntax error. I am really stupid I know but could you please??


    Sub save_Click()
    On Error GoTo Err_save_Click

    If DCount("[Reservation ID]", "Reservations", "[Reservation Date] = " & someDate & " AND [asset ID] = " & AssetID & " AND " & someTimeIn & " BETWEEN [Time Booked Out] AND [Time Booked In] OR " & someTimeOut & " BETWEEN [Time Booked Out] AND [Time Booked In]") > 0 Then
    'asset booked code
    Else
    'asset available code
    End If

    Exit_save_Click:
    Exit Sub

    Err_save_Click:

Posting Permissions

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