MWE
12-16-2007, 02:25 PM
I am running Access2K and WinXP. My first problem is not a VBA issue, but my workaround created some VBA and led to a VBA question ...
1) I have a 2 col by 8 row combo box on form "A", The combo box allows me to select from a group of dates, each date (col1) has a corresponding label (col2) . One of dates needs to be "today", the rest are static. I initially tried to use the Date() function in the RowSource property for the combo box. Since Date() works for other properties, it seemed like a good choice. But Date() did not work. Any suggestions how I might accomplish this?
2) As a workaround to the above, I wrote a VBA proc to change the first element of the RowSource Property to today's date. This approach works fine as long as the VBA proc executes when the form is displayed the first time; reexecuting the proc each time the form is displayed is OK. This brings me to my next question: Is there something in Access equivalent to the UserForm_Activate procedure in MS Forms?
3) The default value for the combo box is today's date. In the Default Value property field I entered =Date() This works for text boxes and did not generate an error. However, when I create a new record, the value in the combo box is #Name? indicating that Access either does not understand =Date() as a default value or does not know where to put it. Text values in quotes for the default value, e.g., "ABC", generate a different error, i.e., #Error
Text values in quotes for other combo boxes (all 1 col) in this form work fine. Clearly I am missing something ...
Thanks for any help.
1) I have a 2 col by 8 row combo box on form "A", The combo box allows me to select from a group of dates, each date (col1) has a corresponding label (col2) . One of dates needs to be "today", the rest are static. I initially tried to use the Date() function in the RowSource property for the combo box. Since Date() works for other properties, it seemed like a good choice. But Date() did not work. Any suggestions how I might accomplish this?
2) As a workaround to the above, I wrote a VBA proc to change the first element of the RowSource Property to today's date. This approach works fine as long as the VBA proc executes when the form is displayed the first time; reexecuting the proc each time the form is displayed is OK. This brings me to my next question: Is there something in Access equivalent to the UserForm_Activate procedure in MS Forms?
3) The default value for the combo box is today's date. In the Default Value property field I entered =Date() This works for text boxes and did not generate an error. However, when I create a new record, the value in the combo box is #Name? indicating that Access either does not understand =Date() as a default value or does not know where to put it. Text values in quotes for the default value, e.g., "ABC", generate a different error, i.e., #Error
Text values in quotes for other combo boxes (all 1 col) in this form work fine. Clearly I am missing something ...
Thanks for any help.