Results 1 to 3 of 3
  1. #1
    Perfac's Avatar
    Perfac is offline Expert
    Windows 7 64bit Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618

    Error in Expression

    PayeBelow65b: Nz(DLookUp("[YoungerThan65]","q03PAYEWeekly",[Wage075b] & " Between [StartAmount065b] And [EndAmount065b] And #" & Format([WageDate075],"yyyy/mm/dd") & "# Between [StartDate065b] And [EndDate065b]"),0)



    YoungerThan65 - Currency
    Wage075b - Currency
    StartAmount065b - Currency
    EndAmount065b - Currency
    WagesDate075 - Date
    StartDate065b - Date
    EndDate065b - Date

    I haven't encountered any errors with this code until recently and have no clue what has changed, but received the following error when trying to use the field on a report and displays as "#Error" in the query records when Wage075b has a decimal value

    "Syntax Error (comma) in query expression '1562,5 Between [StartAmount065b] And [EndAmount065b] And #2017/01/06# Between [StartDate065b] And [EndDate065b]"

    I think the problem lies within Wage075b not being 1562.5(with a period and not a comma)

    I have tried controlling the format with Ccur() but it hasn't changed anything.

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,523
    would it be easier to use a query using these params?
    but
    what about converting every field outside the quotes, (like you did the FORMAT part):

    Nz(DLookUp("[YoungerThan65]","q03PAYEWeekly",[Wage075b] & " Between " & me.StartAmount065b & " And " & me.EndAmount065b & " And #" & Format([WageDate075],"yyyy/mm/dd") & "# Between " & me.StartAmount065b & " And " & me.EndAmount065b ),0)

    and do you need the FORMAT? A date field should be usable without a format since it is a date.

  3. #3
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,002
    If you have even a smallish amount of records this would be much more efficient if you joined the table with the rates into the query directly.
    A dlookup() in a query will cause a seperate background query to run for each record. Very slow and inefficient.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

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

Similar Threads

  1. Replies: 2
    Last Post: 09-10-2014, 11:30 AM
  2. Replies: 11
    Last Post: 05-01-2014, 11:56 AM
  3. Replies: 3
    Last Post: 03-05-2013, 11:17 AM
  4. Replies: 6
    Last Post: 05-30-2012, 12:32 PM
  5. Replies: 1
    Last Post: 05-11-2012, 10:59 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