locked
Writing months as field name, as user selects the start month RRS feed

  • Question

  • Hi all good day, I wanted to enter month as tee field of a table once the user selects the first month as he wish. E.g. If user enters March, I want to enter rest of the months as field names of a table including the month that the user entered.

    Thanks
     
    Saturday, November 28, 2009 10:31 AM

Answers

  • Hi all good day, I wanted to enter month as tee field of a table once the user selects the first month as he wish. E.g. If user enters March, I want to enter rest of the months as field names of a table including the month that the user entered.

    Thanks
     
    CLOSE DATABASES ALL 
    CREATE CURSOR crsTest (Id i)
    lnMonth = 3 &&& The User select March
    lcText = [ALTER Table crsTest ADD Column ]
    FOR lnCount = lnMonth TO lnMonth+11
        lcCommand = m.lcText + CMONTH(DATE(2009, IIF(lnCount <= 12, m.lnCount, m.lnCount - 12),1))+ [ Char(10)]
        EXECSCRIPT(m.lcCommand)
    NEXT 
    BROWSE NORMAL
    or
    CLOSE DATABASES ALL 
    CREATE CURSOR crsTest (Id i)
    lnMonth = 3 &&& The User select March
    lcText = [ALTER Table crsTest ADD Column ]
    FOR lnCount = lnMonth TO 12
        lcCommand = m.lcText + CMONTH(DATE(2009, m.lnCount, 1))+ [ Char(10)]
        EXECSCRIPT(m.lcCommand)
    NEXT 
    BROWSE NORMAL

    • Proposed as answer by Naomi N Sunday, November 29, 2009 8:00 PM
    • Marked as answer by Martin Xie - MSFT Friday, December 4, 2009 7:00 AM
    Saturday, November 28, 2009 3:56 PM

All replies

  • Hi all good day, I wanted to enter month as tee field of a table once the user selects the first month as he wish. E.g. If user enters March, I want to enter rest of the months as field names of a table including the month that the user entered.

    Thanks
     
    CLOSE DATABASES ALL 
    CREATE CURSOR crsTest (Id i)
    lnMonth = 3 &&& The User select March
    lcText = [ALTER Table crsTest ADD Column ]
    FOR lnCount = lnMonth TO lnMonth+11
        lcCommand = m.lcText + CMONTH(DATE(2009, IIF(lnCount <= 12, m.lnCount, m.lnCount - 12),1))+ [ Char(10)]
        EXECSCRIPT(m.lcCommand)
    NEXT 
    BROWSE NORMAL
    or
    CLOSE DATABASES ALL 
    CREATE CURSOR crsTest (Id i)
    lnMonth = 3 &&& The User select March
    lcText = [ALTER Table crsTest ADD Column ]
    FOR lnCount = lnMonth TO 12
        lcCommand = m.lcText + CMONTH(DATE(2009, m.lnCount, 1))+ [ Char(10)]
        EXECSCRIPT(m.lcCommand)
    NEXT 
    BROWSE NORMAL

    • Proposed as answer by Naomi N Sunday, November 29, 2009 8:00 PM
    • Marked as answer by Martin Xie - MSFT Friday, December 4, 2009 7:00 AM
    Saturday, November 28, 2009 3:56 PM
  • Hi, Dear Vladimir Zografski,

    I got your reply, that's the one I expected, Thank you very much for your prompt response

    Regards

    Gaminda
    Sunday, November 29, 2009 4:22 AM