COmbo boxes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sajitk
    New Member
    • Feb 2008
    • 77

    COmbo boxes

    One more question:

    I have a combo box called Period, which taken inputs from users for the period of subscription. The maximum period for subscription is 3 years.

    I also have another combo showing Months called subscription start month and a text box wich displays the current year.

    The user selects the period of subscription and the start month from the combo,
    the application should automatically display the end month in the field subscription end month and the end year in the text box subcription end year

    Thanks in advance
    Sajit

    --------------------------------------------------------------------------------
  • Delerna
    Recognized Expert Top Contributor
    • Jan 2008
    • 1134

    #2
    If period is in whole years only. ie 1 2 or 3 years
    then calculate the number of months ie period*12 and continue as below
    If period is in months then leave period as it is

    make a date from startyear and startmonth
    and add period to it and then separate the year and month again

    and then set the combo boxes so the correct values are selected

    Comment

    • sajitk
      New Member
      • Feb 2008
      • 77

      #3
      Dear Delerna,

      Thanks for the reply....Can you just elaborate on this....i just didnt understand...

      Sajit

      Originally posted by Delerna
      If period is in whole years only. ie 1 2 or 3 years
      then calculate the number of months ie period*12 and continue as below
      If period is in months then leave period as it is

      make a date from startyear and startmonth
      and add period to it and then separate the year and month again

      and then set the combo boxes so the correct values are selected

      Comment

      • missinglinq
        Recognized Expert Specialist
        • Nov 2006
        • 3533

        #4
        How do the months appear in your Months combobox, i.e. Jan, Feb, Mar
        or
        January, February, March

        or
        01, 02, 03

        Which of the above formats do you want the month to have in the subscription end month field?

        What values are in the Period combobox; months or years? Are they formatted as 1, 2, 3 or One, Two, Three?

        Linq ;0)>

        Comment

        • Delerna
          Recognized Expert Top Contributor
          • Jan 2008
          • 1134

          #5
          sorry, assuming
          period is in months
          StartYear is "2008"
          StartMonth is "03" (march)

          what i meant was

          make a date from StartYear and StartMonth
          StartDte=cDate( "01/" & StartMonth & "/" & StartYear) so Dte= 01/03/2008

          now add the period to that date
          EndDte=DateAdd( "m",Period,Star tDte) if period=13 then Dte=01/04/2009

          Now split the year and month for the display controls
          EndYear=Year(En dDte)
          EndMonth=Month( EndDte)

          Now just set the controls to those values.

          Hope that helps

          Comment

          • missinglinq
            Recognized Expert Specialist
            • Nov 2006
            • 3533

            #6
            Originally posted by delerna
            make a date from StartYear and StartMonth
            StartDte=cDate( "01/" & StartMonth & "/" & StartYear) so Dte= 01/03/2008

            now add the period to that date
            EndDte=DateAdd( "m",Period,Star tDte) if period=13 then Dte=01/04/2009
            You need to keep in mind, delerna, when doing this sort of thing with dates, that much of the civilized world uses a default date format of mm/dd/yyyy. Using your code on a PC in any of these countries will always result in a StartDte and EndDte in the month of January!

            Linq ;0)>

            Comment

            • Delerna
              Recognized Expert Top Contributor
              • Jan 2008
              • 1134

              #7
              correction
              make a date from StartYear and StartMonth
              StartDte=cDate( StartMonth & "/01/" & StartYear) so Dte= 03/01/2008

              now add the period to that date
              EndDte=DateAdd( "m",Period,Star tDte) if period=13 then Dte=04/01/2009

              Comment

              • missinglinq
                Recognized Expert Specialist
                • Nov 2006
                • 3533

                #8
                Dealing with dates in an international forum is always a hairball! And we still need the answers to the questions I posed earlier! If StartMonth is Jan or January instead of 1 or 01 then it'll have to be parsed into 01 before being plugged into your formula. We also need the answer to whether Period is in months or years.

                Linq ;0)>

                Comment

                • sajitk
                  New Member
                  • Feb 2008
                  • 77

                  #9
                  Sorry for the late reply


                  the months appear as January, February etc.....

                  The period appear as 1, 2, 3 respectively

                  Sajit

                  Originally posted by missinglinq
                  How do the months appear in your Months combobox, i.e. Jan, Feb, Mar
                  or
                  January, February, March

                  or
                  01, 02, 03

                  Which of the above formats do you want the month to have in the subscription end month field?

                  What values are in the Period combobox; months or years? Are they formatted as 1, 2, 3 or One, Two, Three?

                  Linq ;0)>

                  Comment

                  • missinglinq
                    Recognized Expert Specialist
                    • Nov 2006
                    • 3533

                    #10
                    Three final questions:

                    I'm assuming that a one year subscription is 12 issues, and if it starts in January 2008 then it will end in December 2008. Is this correct?

                    Period is in years, correct?

                    Your PC's Regional Settings are for the USA, correct? Which is to say the default Date format would be mm/dd/yyyy.

                    If all of the above are true, then this should do the job:

                    [CODE=vb]Private Sub StartMonth_Afte rUpdate()
                    StartDate = Me.StartMonth & " " & " 01 " & Me.StartYear
                    EndDate = DateAdd("m", (Me.Period * 12) - 1, StartDate)
                    Me.EndMonth = Format(EndDate, "mmmm")
                    Me.EndYear = Year(EndDate)
                    End Sub
                    [/CODE]
                    If all of the above are not correct, post back and we'll make adjustments.

                    Linq ;0)>

                    Comment

                    Working...