Results 1 to 8 of 8
  1. #1
    Risto85 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    13

    Dlookup error


    Hello

    I'm trying to set Dlookup result as Label caption, but unfortunately I get error message:

    Run time error '3075':

    Syntax error in number in query expression '[Date_Added]=4.02.2015 And [Shift] = '1'.




    Dlookup looks like this:
    Label34.Caption = DLookup("[Spent_Hours]", "249_1_CHours", "[Date_Added]= " & Me.Text27 & " And [Shift] = '" & Me.Text29 & "'")

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Date_Added is a data/time type field? Date parameters need # deliminter.

    Label34.Caption = DLookup("[Spent_Hours]", "249_1_CHours", "[Date_Added]= #" & Me.Text27 & "# And [Shift] = '" & Me.Text29 & "'")

    Are you outside the U.S.? Access accepts the dot in place of / in the date?

    Is Shift a text type field?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Risto85 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    13
    I'm outside US, in Estonia.
    Shift is Numeric field.
    Now when I added # I get following error:

    Syntax error in date in query expression '[Date_Added] = #4.02.2015# And [Shift] ='1'.




    Quote Originally Posted by June7 View Post
    Date_Added is a data/time type field? Date parameters need # deliminter.

    Label34.Caption = DLookup("[Spent_Hours]", "249_1_CHours", "[Date_Added]= #" & Me.Text27 & "# And [Shift] = '" & Me.Text29 & "'")

    Are you outside the U.S.? Access accepts the dot in place of / in the date?

    Is Shift a text type field?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Since Shift is a numeric field, remove the apostrophe delimiters from around Me.Text29. Apostrophe delimiters are for text fields, # for date/time, nothing for numeric.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Risto85 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    13
    Hi,

    I still get error with formula Label34.Caption = DLookup("[Spent_Hours]", "249_1_CHours", "[Date_Added]= #" & Me.Text27 & "# And [Shift] = " & Me.Text29 & " "):

    Syntax in date in query expression '[Date_Added]=#4.02.2.015# And [Shift]= 2'.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Remove the & " " at the end of the expression. This could be concatenating a space to the Text29 value.

    Also, I suspect the periods in the date are not being handled by Access. Try:

    Replace(Me.Text27, ".", "/")
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Risto85 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    13
    Label34.Caption = DLookup("[Spent_Hours]", "249_1_CHours", "[Date_Added]= " & Me.Text27 & " And [Shift] = " & Me.Text29)

    Error is: Syntax error in number in query expression '[Date_Adde] = 4.02.2015 And [Shift='.

    It can find date but there is problem getting the shift number correctly.

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    This does not make sense. Going in circles. If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. DLOOKUP #Error
    By neo651 in forum Forms
    Replies: 6
    Last Post: 12-12-2012, 12:54 PM
  2. DLookup Syntax Error
    By uncletreetrunk in forum Programming
    Replies: 4
    Last Post: 07-30-2012, 02:29 PM
  3. DLookup Error
    By uncletreetrunk in forum Programming
    Replies: 5
    Last Post: 07-16-2012, 08:33 PM
  4. Error in Dlookup?
    By cindytan in forum Forms
    Replies: 1
    Last Post: 02-07-2012, 02:40 AM
  5. DLookup error
    By jgelpi16 in forum Programming
    Replies: 3
    Last Post: 08-25-2010, 07:26 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