Full Version: Setting a Default Value
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
sorbit
I have a combo box on a form that lists every Thursday in 2006. Every Friday, the Thursday selected moves up one week. To make things easier for the user, I would like the combo box to default back to value last selected whenever the Form is opened. Does anyone know how to do that?
ScottGem
In the After Updaste event put:

Me.controlname.Default = Me.Controlname
sorbit
I am receiving an error message: Method or data member not found
ScottGem
Ok, You need to use the wizards Access provides.

If you type Me. inthe VBE, you will get a list of all possible members of the Form collection. Included in that collection are all the controls on the form. From there you can select the controlname. After you select the controlname you press another dot and you will get a list of all the properties of that control. One of those properties will be Default or Default value or something like that.

No one here remembers every exact syntax or command. Since we volunteer our time here we don't always check to make sure our advice is syntactically correct. But we give you enough so you can figure it out. If you had typed out the commands as I show above you would have seen that Default may not have been the exact property.
sorbit
Thanks Scott. I typed in Me which brought up a list. I selected ctl3week (under the Other tab I have 3week, but that was not available) and default was not available, so I selected defaultvalue. It is still giving me an error; I'm baffled.
sorbit
It appears as though I may had my Other tab mislabeled since now it is actually changing the values. Strangely, it is now displaying times instead of the dates: 12:00:49 for example. The seconds change as I select different dates. Do you know what might be causing this?
ScottGem
You are storing both data and time, you need to format the control to display Date, not Time.
sorbit
Thanks Scott.
This is really really strange! Now, each time I select a value, it comes up 12/30/1899!!
ScottGem
That means that there is no value being shown. A zero date value translates to 12/30/1899.

What is the RowSource and Bound column of the combo.
sorbit
The row source is a table called tblCurr3Week with one Date/Time field named 3-week start. This table lists the date of every Thursday in 2006. The combo box in the form is set up to select from this table.
ScottGem
There is only ONE field in that table? Can you attach a stripped down copy of your database?
sorbit
Actually, there are dozens of tables in the DB so I just made a copy of the table and the Form into a new DB and zipped it up. Thanks so much for all your help.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.