Results 1 to 9 of 9
  1. #1
    MeanCulture is offline Novice
    Windows Vista Access 2007
    Join Date
    Dec 2013
    Posts
    11

    Run-time error '3075'

    Hello, I am running into some troubles with my vehicle check-out database. I've created a form for members to enter in their info and reserve a vehicle. Then I get the following error:


    Syntax error (missing operator) in query expression "DATERESERVED=' 12/14/2013 8:00AM" And CHECKINDATETIME=#' 12/14/2013 10:00AM And GV=#G14-52005#'.

    My code is:
    Option Compare Database
    Private Sub Command19_Click()
    If DCount("*", "qrydups", "'DATERESERVED='" & Me.DATE_RESERVED & "' And CHECKINDATETIME=#'" & Me.CHECK_IN_DATE_TIME & "' And GV=#'" & Me.GV & "#") > 0 Then
    MsgBox "This GV is available! Click Print Confirmation", , "GV Available"
    Else
    MsgBox "Sorry, this GV is taken! Choose another start/end date and time!", , "Double Booking"
    End If
    Exit_Command138_Click:
    Exit Sub
    Err_Command138_Click:
    MsgBox Err.Description


    Resume Exit_Command138_Click

    End Sub
    And this line is highlighted in yellow with an arrow
    If DCount("*", "qrydups", "'DATERESERVED='" & Me.DATE_RESERVED & "' And CHECKINDATETIME=#'" & Me.CHECK_IN_DATE_TIME & "' And GV=#'" & Me.GV & "#") > 0 Then

    Please help.

    Also would this be the correct way to stop double booking? Any help would be greatly appreciated. Warning you are dealing with a noobie.

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Try:
    If DCount("*", "qrydups", "'DATERESERVED= #" & Me.DATE_RESERVED & "# And CHECKINDATETIME=#" & Me.CHECK_IN_DATE_TIME & "# And GV='" & Me.GV & "'") > 0 Then
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    MeanCulture is offline Novice
    Windows Vista Access 2007
    Join Date
    Dec 2013
    Posts
    11
    That didn't work

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Quote Originally Posted by MeanCulture View Post
    That didn't work
    That remark doesn't really help us. Did you get some other error message.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    If DCount("*", "qrydups", "DATERESERVED= #" & Me.DATE_RESERVED & "# And CHECKINDATETIME=#" & Me.CHECK_IN_DATE_TIME & "# And GV=#" & Me.GV & "#") > 0 Then

    If all three fields are date fields

    If DCount("*", "qrydups", "DATERESERVED= #" & Me.DATE_RESERVED & "# And CHECKINDATETIME=#" & Me.CHECK_IN_DATE_TIME & "# And GV='" & Me.GV & "'") > 0 Then

    If all the field GV is a text field



    If DCount("*", "qrydups", "DATERESERVED= #" & Me.DATE_RESERVED & "# And CHECKINDATETIME=#" & Me.CHECK_IN_DATE_TIME & "# And GV=" & Me.GV) > 0 Then

    If all the field GV is a number field


    you had an extra ' mark in the WHERE clause of your DCOUNT function right after the opening double quote

  6. #6
    MeanCulture is offline Novice
    Windows Vista Access 2007
    Join Date
    Dec 2013
    Posts
    11
    I tried what you said @rpeare

    If DCount("*", "qrydups", "DATERESERVED= #" & Me.DATE_RESERVED & "# And CHECKINDATETIME=#" & Me.CHECK_IN_DATE_TIME & "# And GV='" & Me.GV & "'") > 0 Then

    If all the field GV is a text field

    and the new error is Run-time error '2471' which reads:

    The expression your entered as a query parameter produced this error:
    'DATERESERVED'

  7. #7
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    you have to match the variables to your actual names

    In your query QRYDUPS, do you have a field named DATERESERVED?

    I cut and paste the code from your original post

    if the field is actually named DATE_RESERVED you have to reflect that in your dcount statement

    in the statement:

    If DCount("*", "qrydups", "DATERESERVED= #" & Me.DATE_RESERVED & "# And CHECKINDATETIME=#" & Me.CHECK_IN_DATE_TIME & "# And GV='" & Me.GV & "'") > 0 Then

    each section of the WHERE clause must reflect your actual items in other words:

    DATERESERVED= #" & Me.DATE_RESERVED & "#

    this is saying in your query you must have a field named DATERESERVED (left hand of the equal sign)
    on your form you must have a field named DATE_RESERVED (right hand of the equal sign)

    same goes for the other two variables.

    I suspect you have mistyped the field name from your query for the first and second fields but that's just a guess

  8. #8
    MeanCulture is offline Novice
    Windows Vista Access 2007
    Join Date
    Dec 2013
    Posts
    11
    Fixed. Thank you. This is the final code I used.

    If DCount("*", "qrydups", "[CHECK-OUT DATE/TIME]= #" & Me.DATE_RESERVED & "# And [CHECK-IN DATE/TIME]=#" & Me.CHECK_IN_DATE_TIME & "# And GV='" & Me.GV & "'") > 0 Then

  9. #9
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Just a side note here, it's extremely bad practice to use special characters in your field names with the exception of the underscore (_). It can cause you no end of grief using other characters, for instance the hypen is actually a mathematical (subtraction function) and the slash is a division indicator so if you were to type out your

    check-out date/time without the [] brackets you would really confuse the computer into thinking it was trying to calculate a value on 3 or 4 different fields when that's not at all what you are intending.

    I'd suggest you try to remove all special characters from your object names.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 03-05-2013, 11:17 AM
  2. Need Help with run time error 3075
    By vkumar in forum Forms
    Replies: 14
    Last Post: 07-24-2012, 05:48 PM
  3. Run Time Error '3075'
    By ertweety in forum Programming
    Replies: 2
    Last Post: 06-03-2012, 04:26 PM
  4. Replies: 6
    Last Post: 05-30-2012, 12:32 PM
  5. Replies: 5
    Last Post: 03-27-2012, 01:40 PM

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