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

    Function


    Dear Experts,

    I am using the following function to get the Budgeted Seed Rate on a given market date:

    Public Function GetSdBudgetRate(MktCenter As Integer, MktVty As Integer, MktDt As Date, factoryType As String) As Double
    If [factoryType] = "TMC" Then
    GetSdBudgetRate = Nz(DLookup("budgetedSeedRate", "BudgetAndMktQry", "dateOfMarket=#" & MktDt & "# And[marketInCenter]=" & [MktCenter] & "And[varietyArrived]=" & [MktVty]), 0)
    Else
    GetSdBudgetRate = Nz(DLookup("budgetedSeedRate-Con", "BudgetAndMktQry", "dateOfMarket=#" & MktDt & "# And[marketInCenter]=" & [MktCenter] & "And[varietyArrived]=" & [MktVty]), 0)
    End If
    End Function

    For some dates it returns the Rate, but for some dates, even though data is available, it returns 0. My system's OS is Windows 7 Professional and I am using MS Access 2007. When I tried this in a system having Windows XP, it worked fine.
    Is there anything wrong in the code?

    Regards,
    Alex

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,915
    Can you test on another Windows 7 system?

    I can't see anything wrong with the code. I would have thought the lack of spaces before and after the And operator would cause issue but I tested that and it worked. Probably included [] around field names is reason.
    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
    Alex Motilal is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Nov 2008
    Location
    Coimbatore, India
    Posts
    192

    Function Error

    Dear June7,
    As you suggested I tried in another Windows7 Professional System and the problem persists. Do you think it may due to Windows7 Professional OS?
    Alex

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,915
    Certainly makes one suspicious. If you want to provide db I will test with my Windows 7 Home Premium. 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.

  5. #5
    Alex Motilal is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Nov 2008
    Location
    Coimbatore, India
    Posts
    192

    Problem with function

    Deaar June7,

    I tested with a Windows7 Home Premium system. It works fine. I think the problem is that the function does not work properly with Windows7 Professional. It doesn't work with certain dates only. For example November 3 of any given year. Is it possible to contact Microsoft? If so how to contact and put up the problem?

    Regards,
    Alex

  6. #6
    Dunro is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Location
    Toronto, Canada
    Posts
    39
    Quote Originally Posted by Alex Motilal View Post
    Deaar June7,

    I tested with a Windows7 Home Premium system. It works fine. I think the problem is that the function does not work properly with Windows7 Professional. It doesn't work with certain dates only. For example November 3 of any given year. Is it possible to contact Microsoft? If so how to contact and put up the problem?
    Are all your dates in the same format? I find Access to be temperamental with dates (my computer's region settings are set to Canada, but Access still requires American date format, etc). I have started adding functions to various queries to ensure that all dates are formatted correctly.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,915
    Seems to me if the date is cause then it should be same for all computers. Review http://allenbrowne.com/ser-36.html

    Support from Microsoft? You could try http://support.microsoft.com/ph/915/en-us

    Good luck!
    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. Iif function
    By Bertrand82 in forum Access
    Replies: 2
    Last Post: 02-04-2013, 05:58 AM
  2. Between function
    By brownk in forum Queries
    Replies: 2
    Last Post: 09-10-2012, 08:33 AM
  3. Need help with IIF function
    By RazMan in forum Access
    Replies: 4
    Last Post: 10-28-2010, 12:07 PM
  4. Want function to get current function name
    By Davis DeBard in forum Programming
    Replies: 2
    Last Post: 08-13-2009, 05:02 AM
  5. Sum Function Help
    By newbie in forum Reports
    Replies: 3
    Last Post: 06-30-2009, 05: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