Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. In Access: group of records and assign conditional group ?

In Access: group of records and assign conditional group ?

Scheduled Pinned Locked Moved Database
helpcomtutorialquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 2456424
    wrote on last edited by
    #1

    In Access I want to group and assign data according to conditions with 2 values 0 and 1 (true or false) and with the condition NGAYGIAO>= #01/01/2019# and NGAYGIAO <=# 31/01/2019# me How to write commands ? The data I put in the excel file consists of two sheets: Original data and Result, where Original data is the original data sheet that is the result of the problem I need, when running the access issue, ask you to help me with the problem. http://www.mediafire.com/file/hkkw519bw2k3o9h/baitap\_data2.xls/file

    V C 2 Replies Last reply
    0
    • U User 2456424

      In Access I want to group and assign data according to conditions with 2 values 0 and 1 (true or false) and with the condition NGAYGIAO>= #01/01/2019# and NGAYGIAO <=# 31/01/2019# me How to write commands ? The data I put in the excel file consists of two sheets: Original data and Result, where Original data is the original data sheet that is the result of the problem I need, when running the access issue, ask you to help me with the problem. http://www.mediafire.com/file/hkkw519bw2k3o9h/baitap\_data2.xls/file

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #2

      Your problem description is not very clear, so it's hard to guess what you do and what you need... However, you could rewrite your condition for NGAYGIAO as

      NGAYGIAO BETWEEN #01/01/2019# AND #31/01/2019#

      which looks more readable.

      U 2 Replies Last reply
      0
      • U User 2456424

        In Access I want to group and assign data according to conditions with 2 values 0 and 1 (true or false) and with the condition NGAYGIAO>= #01/01/2019# and NGAYGIAO <=# 31/01/2019# me How to write commands ? The data I put in the excel file consists of two sheets: Original data and Result, where Original data is the original data sheet that is the result of the problem I need, when running the access issue, ask you to help me with the problem. http://www.mediafire.com/file/hkkw519bw2k3o9h/baitap\_data2.xls/file

        C Offline
        C Offline
        Chris Quinn
        wrote on last edited by
        #3

        Add a derived column to your selection where the definition is as follows: =IIF(NGAYGIAO BETWEEN #01/01/2019# and #31/01/2019 23:59:59#,true,false) You can then sort and group by this column

        ========================================================= I'm an optoholic - my glass is always half full of vodka. =========================================================

        1 Reply Last reply
        0
        • V Victor Nijegorodov

          Your problem description is not very clear, so it's hard to guess what you do and what you need... However, you could rewrite your condition for NGAYGIAO as

          NGAYGIAO BETWEEN #01/01/2019# AND #31/01/2019#

          which looks more readable.

          U Offline
          U Offline
          User 2456424
          wrote on last edited by
          #4

          from the original data I created the result, if the contract in the month has LOAIHD = "FBAN" and between (#01/01/2019# and #31/01/2019#) then [BOOL] = 1 else [BOOL = 0, I will describe the condition of [BOOL] in C# code

          for (int i = 0; i < [Original data].Count; i++)
          {
          bool BOOLEAN = 0;
          string SOHD = "";
          if([NGAYGIAO].[i]>=#1/1/2019# && [NGAYGIAO].[i] <=#1/31/2019#) //dd/MM/yyyy
          {
          for (int j = 0; j < [Original data].Count; j++)
          {
          if([LOAIHD].[j] == "FBAN")
          {
          BOOLEAN = 1;
          SOHD = [Original data].[HD].[j];
          }
          }
          }
          if(SOHD == [Original data].[HD].[i] && SOHD != "")
          {
          [Result].[BOOL].[i] = BOOLEAN;
          }
          }

          1 Reply Last reply
          0
          • V Victor Nijegorodov

            Your problem description is not very clear, so it's hard to guess what you do and what you need... However, you could rewrite your condition for NGAYGIAO as

            NGAYGIAO BETWEEN #01/01/2019# AND #31/01/2019#

            which looks more readable.

            U Offline
            U Offline
            User 2456424
            wrote on last edited by
            #5

            from the original data I created the result, if the contract in the month has LOAIHD = "FBAN" and between (#01/01/2019# and #31/01/2019#) then [BOOL] = 1 else [BOOL = 0, I will describe the condition of [BOOL] in C# code [CODE] for (int i = 0; i < [Original data].Count; i++) { bool BOOLEAN = 0; string SOHD = ""; if([NGAYGIAO].[i]>=#1/1/2019# && [NGAYGIAO].[i] <=#1/31/2019#) //dd/MM/yyyy { for (int j = 0; j < [Original data].Count; j++) { if([LOAIHD].[j] == "FBAN") { BOOLEAN = 1; SOHD = [Original data].[HD].[j]; } } } if(SOHD == [Original data].[HD].[i] && SOHD != "") { [Result].[BOOL].[i] = BOOLEAN; } } [/CODE]

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups