Results 1 to 11 of 11
  1. #1
    Clarkeyboy is offline Novice
    Windows 10 Access 2007
    Join Date
    Feb 2018
    Posts
    11

    SQL Where clause error

    I'm new to VBA so this is most likely user error, but I am creating a doctor appointment system...
    I'm trying to create an SQL statement that selects a date and gives available times on the chosen date
    I have a combo box with available times, however, this error prevents this function from working.
    Any help much appreciated
    Attached Thumbnails Attached Thumbnails Access.PNG  

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    You need a space between " & AND

    Does the form have a control called ID and is it a number field?
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    Clarkeyboy is offline Novice
    Windows 10 Access 2007
    Join Date
    Feb 2018
    Posts
    11
    Okay, I have added the space
    There isn't a control called ID on my form currently

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    There isn't a control called ID on my form currently
    that is the reason for your error, it needs to be there, if not as a control, then as a field in the form recordset

  5. #5
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    Also need space in front of Where

  6. #6
    Clarkeyboy is offline Novice
    Windows 10 Access 2007
    Join Date
    Feb 2018
    Posts
    11
    Thanks
    But.... How would I do that?
    I'm a noob

  7. #7
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Like this
    " WHERE
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  8. #8
    Clarkeyboy is offline Novice
    Windows 10 Access 2007
    Join Date
    Feb 2018
    Posts
    11
    Ah, i got that bit, I meant how i make a control called ID and make it a number field?

  9. #9
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    it should be in your form recordsource - perhaps it is called DoctorsID?

    another typo - you select DoctorsID, but then are searching on DoctoID

  10. #10
    Clarkeyboy is offline Novice
    Windows 10 Access 2007
    Join Date
    Feb 2018
    Posts
    11
    Form Properties>>Record Source is set to the table containing my doctor information
    If I type the DoctorsID into the Record Source, it says it is an invalid record source...

  11. #11
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    The recordsource for your form is either a table name, a query name, or an SQL string.
    One of the fields in the above must contain the field (which might be DoctorsID) that you are searching for in your WHERE clause.

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

Similar Threads

  1. Syntax error in From clause
    By GraeagleBill in forum Queries
    Replies: 9
    Last Post: 12-16-2014, 03:47 PM
  2. Replies: 13
    Last Post: 05-30-2014, 04:07 PM
  3. syntax error in from clause
    By jskamm in forum Access
    Replies: 2
    Last Post: 09-18-2012, 09:13 AM
  4. Syntax Error in FROM clause
    By cjohnston in forum Queries
    Replies: 2
    Last Post: 02-15-2012, 07:33 AM
  5. FROM Clause error message
    By skylite in forum Queries
    Replies: 2
    Last Post: 10-23-2008, 05:47 AM

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