Results 1 to 9 of 9
  1. #1
    Alex Motilal is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Nov 2008
    Location
    Coimbatore, India
    Posts
    192

    DLookup Function

    I am using Access 2007. The problem is in the following Function:

    Public Function GetSeason(SeasonalDate As Date) As String
    GetSeason = Nz(DLookup("[PurchaseSeason]", "tblSeason", "[SeasonStartDT]<= #" & SeasonalDate & "# And [SeasonEndDT]>= #" & SeasonalDate & "#"), "")
    End Function

    For the Season 2013-14, the first date is 1st October 2013 and the last date is 31st September 2014. The Query returns Null for the following 3 dates:
    10th January 2014, 11th January 2014 and 12th January 2014.


    For all other dates, the Function returns the correct Season including 9th & 13th January 2014. This baffles me. Can anyone suggest what may be the problem. I tried Allen Brown's ELookup Function and it also gives the same result. Can anyone suggest what to do?

    Alex

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,543
    What date format do you use dd/mm/yyyy or mm/dd/yyyy
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Alex Motilal is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Nov 2008
    Location
    Coimbatore, India
    Posts
    192
    I am using dd/mmm/yyyy format.

  4. #4
    Alex Motilal is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Nov 2008
    Location
    Coimbatore, India
    Posts
    192
    Sorry. Actually it is dd/mm/yyyy Format.

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by Alex Motilal View Post
    Sorry. Actually it is dd/mm/yyyy Format.
    I suspect that that is the problem; MS Access is US-centric, when it comes to dates! Allen Browne explains the ins-and-outs of using date formats other than the US format with Access, here:

    International Dates in Access

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    Alex Motilal is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Nov 2008
    Location
    Coimbatore, India
    Posts
    192
    Thank u Missinglinq,
    My system setting is also in dd/mm/yyyy format. However, the problem persists. I tried examples for the same days in future dates (ie., 10/01/2015, 10/01/2016 and so on) and the same problem repeats.
    Regards,
    Alex

  7. #7
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    What is the "[SeasonStartDT]" defined in the table? Is it "DateTime" data type or "Text"?

    You can try to put "#" around "[SeasonStartDT]" and [SeasonEndDT]". Like
    "#" & "[SeasonStartDT]" & "#"
    "#" & "[SSeasonEndDT" & "#"

  8. #8
    Alex Motilal is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Nov 2008
    Location
    Coimbatore, India
    Posts
    192
    Both [SeasonStartDt] and [SeasonEndDt] fields are Date/Time and formatted to Medium Date. I tried with "#" as you suggested and again I am getting erratic results.
    Alex

  9. #9
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Can you provide a dB of JUST the table "tblSeason"?

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

Similar Threads

  1. Dlookup function Help
    By bronson_mech in forum Forms
    Replies: 20
    Last Post: 07-07-2013, 05:04 AM
  2. Dlookup Function
    By MarkHenderson in forum Queries
    Replies: 1
    Last Post: 11-19-2012, 03:00 PM
  3. DLOOKUP function
    By tariq1 in forum Programming
    Replies: 5
    Last Post: 07-17-2012, 04:22 PM
  4. DlookUp Function.
    By cap.zadi in forum Forms
    Replies: 11
    Last Post: 09-22-2011, 12:56 PM
  5. Need Help for Dlookup function
    By wasim_sono in forum Programming
    Replies: 5
    Last Post: 01-04-2006, 08:18 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