Question Field Default value in double quotes

Isskint

Slowly Developing
Local time
Today, 23:24
Joined
Apr 25, 2012
Messages
1,302
On an existing DB i have set a default value for a field. The customer has now asked that they be able to change this default. I thought, hey, no big problem. They have SuperUsers, so i included a little pop up form that lists all the current valid values for that field (from a look up table). If the default value needs to change a superuser can access this and select the new default. That works fine. The trouble comes when setting the default value on a form. I figured a simple bit of VBA in the OnOpen event - Me.cmbTypes.Value = Me.cmbTypes.DefaultValue - should work. However the value it returns from the default is ""xxxx"" and as such it is read as "". I can work around it by removing the extra " " but WHY does it do this? Would it be better to set this up as a custom property of the DB?

Using Access 2003
 
What code do you actually have and where is it placed? In the form event or on the control?
 
If you want that value to be editable, it's better store the value in a table and have it looked up on form's Before Insert event.
 
Thanks both for your replies.

Trevor G, the code is simply Me.cmbTypes.Value = Me.cmbTypes.DefaultValue and this is in the OnOpen form event and also used to set a control for data entry purposes.

G37Sam, it is unnecessary to have 1 record, 1 field tables when there are other options. I often use tag property for storing bits of 'hidden' data OR as i mentioned a custom database property (which can be accessed for I/O via this bit of code;
CurrentDb.Containers!Databases.Documents!UserDefined.Properties("CustomPropertyTitle").Value

Just on this occasion i thought the defaultValue (seing how that is a supplied property) would suffice.
 
And can these values be changed and permanently stored easily in runtime?

Every DB I build has a table just for tiny bits of data like this. Makes life a lot easier.
 
Hi G37Sam

Using Custom Properties has always worked for me, but then my databases have always stayed on one machine (as an mdb or accdb) OR been split with the back end stored on a company server and the front end 'distibuted' as needed - so carrying the CustomProperties.

Yes the values can be edited using the line of code i posted:

to read it: x = CurrentDb.Containers!Databases.Documents!UserDefin ed.Properties("CustomPropertyTitle").Value

to write to it: CurrentDb.Containers!Databases.Documents!UserDefin ed.Properties("CustomPropertyTitle").Value=x

I do use the seperate table method when i have a number of settings that may need changing but not for a single setting
 

Users who are viewing this thread

Back
Top Bottom