Results 1 to 4 of 4
  1. #1
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451

    proper syntax for where clause with multiple

    can someone help with the syntax of the where clause. i am summing the hours worked per craft but on the last if statement is need to sum the total of several craftid's together.


    Code:
        Dim t As Date
        Dim a As Date
        Dim c As Date
        If Not IsNull(DLookup("hours", "workquecraftt", "WorkQueID=" & [WorkQueID] & "and  craftid=4")) Then
            t = DSum("Hours", "workquecraftt", "WorkQueID=" & [WorkQueID] & "and  craftid=4")
            txttotal4 = t
        Else
            txttotal4 = 0
        End If
        
        If Not IsNull(DLookup("hours", "workquecraftt", "WorkQueID=" & [WorkQueID] & "and  craftid=5")) Then
            a = DSum("Hours", "workquecraftt", "WorkQueID=" & [WorkQueID] & "and  craftid=5")
            txttotal5 = a
        Else
            txttotal5 = 0
        End If
            If Not IsNull(DLookup("hours", "workquecraftt", "WorkQueID=" & [WorkQueID] & " and  craftid=1,2,3,6 ")) Then
            c = DSum("Hours", "workquecraftt", "WorkQueID=" & [WorkQueID] & " and  craftid=1,2,3,6 ")
            txttotalcont = c
        Else
            txttotalcont = 0
        End If
    im getting a runtime error 3075 on the last if statement where i have the 1,2,3,6

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Can't remember if In works in a DSum(), if so

    craftid In(1,2,3,6)

    if not

    craftid = 1 Or craftid = 2 Or...
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    thanks paul, the crafted in() did work in a dsum

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Proper Foreign Key Syntax?
    By nomadsoul in forum Access
    Replies: 4
    Last Post: 10-28-2015, 04:40 PM
  2. Syntax error in From clause
    By GraeagleBill in forum Queries
    Replies: 9
    Last Post: 12-16-2014, 03:47 PM
  3. Replies: 10
    Last Post: 04-01-2014, 05:01 PM
  4. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 AM
  5. Where clause syntax
    By stupesek in forum Reports
    Replies: 7
    Last Post: 09-03-2010, 02:26 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