Results 1 to 8 of 8
  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 Syntax Error

    Me!Wek_ID041 = ("WekID052","q01Week","#Format(Me!PublicHolidayDat e041, "yyyy-mm-dd")# & " Between(FstDayOfWeek052 And LstDayOfWeek052")



    I am trying to get the correct expression to get the correct week ID from query q01week.
    Click image for larger version. 

Name:	Week.png 
Views:	16 
Size:	140.1 KB 
ID:	36763Click image for larger version. 

Name:	Week2.png 
Views:	16 
Size:	174.7 KB 
ID:	36764

  2. #2
    Perfac's Avatar
    Perfac is offline Expert
    Windows 7 64bit Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Sorry, wrong query, this is the correct query.
    Click image for larger version. 

Name:	Week3.png 
Views:	16 
Size:	138.6 KB 
ID:	36765

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Everything on the right side of = sign is nonsense. Are you trying to do a DLookup()?

    If you want the week number of a date value, consider:

    DatePart("ww",Date())

    or

    Format(Date(),"ww")

    The first returns a number, the second returns a string.
    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.

  4. #4
    Perfac's Avatar
    Perfac is offline Expert
    Windows 7 64bit Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    I send a reply a minute ago, now I don't see it. I am short of sleep, bad concentration errors. Partner came in just now and fixed it, it works.

    Me!Wek_ID041 = DLookup("WekID052", "q01Week", "#" & Format(Me!PubHolidayDate041, "yyyy-mm-dd") & "# Between [FstDayOfWeek052] And [LstDayOfWek052]")

  5. #5
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    Are you absolutely sure that filter criteria works for all dates?
    The date formatting should be applied to the date range and not the field itself

    To my mind it should look like this:

    Code:
    Me.Wek_ID041 = DLookup("WekID052", "q01Week","PubHolidayDate041 Between #" & Format([FstDayOfWeek052],"yyyy-mm-dd") & "# And #" & Format([LstDayOfWeek052],"yyyy-mm-dd") & "#")
    I'm writing this on a tablet but hopefully no errors above
    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

  6. #6
    Perfac's Avatar
    Perfac is offline Expert
    Windows 7 64bit Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Thank you sir. Yes it clearly works. I copied it from where it works to paste it here, no more concentration errors.

  7. #7
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    OK but I'm surprised if all values really are correct as what you wrote is not the correct way to apply formatting to date ranges
    Suggest you check for several date ranges in the first 12 days of the month e.g. between 08-May-2008 and 02-Jul-2008

    What if someone uses a short date format e.g. 05/07/2008?
    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
    Perfac's Avatar
    Perfac is offline Expert
    Windows 7 64bit Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    My son and partner Ruben set it up that way. I showed him your opinion and he thinks your is more correct and he doesn't understand why his works. We have on our wall a list of expressions that comes up frequently. Yours is now on that list and when needed again that will be the way. The format part in the expression was suggested 2 years ago by someone in a different expression and we always use dd-mmm-yyyy in our input fields, but it doesn't matter in what format we enter it works.

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: 4
    Last Post: 07-25-2012, 04:01 AM
  5. Replies: 6
    Last Post: 05-30-2012, 12:32 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