Multiple criteria access query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Pramod Tripathi
    New Member
    • Nov 2011
    • 1

    Multiple criteria access query

    Hi
    I want to make an expression to find out the value of a field particular employee of previous month, and i have put the following expression for it
    prevdays:
    Code:
    DLookUp("[Plus_days_cf]","[ATTENDANCE]","[Emp_code]='" & [ATTENDANCE]![Emp_code] & "'" And "[Month_id]=" & (([ATTENDANCE]![Month_id])-1))
    the criteria i have put give work individually but when i combine them it does not work properly. Please help.
    Thanks in advance.
    Last edited by NeoPa; Nov 11 '11, 11:37 PM. Reason: Added mandatory [CODE] tags for you
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1293

    #2
    Pramod,
    I'm sorry, but "it does not work properly." tells next to nothing about the problem you are encountering. What do you mean by that? What is the specific problem with the result you are getting?

    What do you mean by "the criteria i have put give work individually but when i combine them" ... do you mean if you use only Emp_code in the criteria it works,and only "Month_id" in the criteria work okay but using both do not work?

    Jim

    Comment

    • ashwinidubey
      New Member
      • Nov 2011
      • 5

      #3
      hi
      I mean to say that when i use the month criteria it show the value for that month but for all employees even(although that not i desire, but half work done), when i use the employee code criteria the value is shown for that employee but in every month. I want to find the value of a particular employee in the last month so i use both the criteria together but then it shows the first value in the table for all the employees in every month. I hope I explained properly.
      Please help.
      Thanks.
      Pramod.

      Comment

      • ashwinidubey
        New Member
        • Nov 2011
        • 5

        #4
        i have a table for attendance, in it in a particular month several employees, then in next month and so on. i want a particular fields value to be shown when the criteria matches which if the employee id is same and month id is one less than current, that is previous month.
        how to do it, i used the above expression and that returns the value of the first record for all the months and all the employees.
        Thanks
        Pramod.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32661

          #5
          This wouldn't have been such a mess if you'd posted the question properly in the first place Pramod. It would have been much clearer to everyone that you just mucked up your strings. Try instead :

          Code:
          DLookUp("[Plus_days_cf]","[ATTENDANCE]","[Emp_code]='" & [ATTENDANCE]![Emp_code] & "' And [Month_id]=" & [ATTENDANCE]![Month_id]-1)

          Comment

          Working...