I am creating a main form of sorts that will drive my reports. On this form I will enter the begining date and ending dates to use within my querries. The process by which I enter the dates will be a collection of four combo boxes: cmbBeginMonth, cmbBeginYear, cmbEndMonth, and cmbEndYear. Pretty self-explanatory. I have an 2 unbound text boxes (txtBeginDate and txtEndDate)that displays the selected dates with the 'on click' event of the combo boxes (via the control property being equal to =[cmbBeginMonth] &"-"&[cmbBeginYear]). The format of these dates are 'mm-yyyy'. Now my problem is in the validating of these dates. I just have a simple comand button with code attached that will validate the dates.
By the way, the structure in which I have the Month combo boxes setup is 2 columns with col1 being 01, 02, 03,etc and col2 being Jan, Feb, Mar, etc. Col1 is bound. The year is 1cols : 1998;1999;2000;2001;2002. For instance I select Mar and 2001 on my beginning side, the text box will read 03-2001.
Now I have a very simple If...Then statement to validate my date range. This validates the data in the two unbound text boxes specifically to see if the beginning date is actually before the ending date. If it is, a message stating it is a valid date range appears; if it is not, it will produce a message that the beginnng date occurs after the ending date. However, that is not what I am receiving. For instance if I select 01-02 thru 03-02 it will tell me it is correct (which it is). However, should I select 01-99 thru 02-98 it still tels me it is correct. Now I can do 02-99 thru 01-99 and it will tell me that it is invalid. It appears that it is only taking into consideration my month value. I will include my code.
Dim strBeginDate, strEndDate As Date
I think the code is getting con-fussed as in one combo box you are referencing column 1 and in the other column 0. You could try and tell it which column is which, or alternatively set up the combo boxes differently.
I suspect strbegindate=ComboMonth.Column(1) & comboYear.Column(0) is required somewhere in your code, prior to formating.