By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,586 Members | 623 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,586 IT Pros & Developers. It's quick & easy.

Retrieve Default Value of a field in SQL Server Table by VBA

P: 1
Hi all,

I am just about to migrate a database from mdb to adp format - and experienced a real difficulty in retrieving a table field's default value by VBA code (using the ADODB 2.8 Library).
In DAO it simply works like this
Expand|Select|Wrap|Line Numbers
  1. set rst = dbobject.OpenRecordset("sqlstatement")
  2. set fld = rst.Fields("FIELD1")
  3. Debug.Print fld.DefaultValue
  4.  
But with ADODB I really got stuck as the ADODB Field Object does not support the property "DefaultValue".

I need this code to determine, if the user entered a new value on the form or if he just left the default value of the field untouched.

Used Access Version is MS ACCESS 2003 SP3

Can anyone help me out of this trouble? - All your ideas are more than welcome and really appreciated.

Thanks a lot in advance,
Klaus
Mar 28 '08 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 374
Hi all,

I am just about to migrate a database from mdb to adp format - and experienced a real difficulty in retrieving a table field's default value by VBA code (using the ADODB 2.8 Library).
In DAO it simply works like this
Expand|Select|Wrap|Line Numbers
  1. set rst = dbobject.OpenRecordset("sqlstatement")
  2. set fld = rst.Fields("FIELD1")
  3. Debug.Print fld.DefaultValue
  4.  
But with ADODB I really got stuck as the ADODB Field Object does not support the property "DefaultValue".

I need this code to determine, if the user entered a new value on the form or if he just left the default value of the field untouched.

Used Access Version is MS ACCESS 2003 SP3

Can anyone help me out of this trouble? - All your ideas are more than welcome and really appreciated.

Thanks a lot in advance,
Klaus
The simplest answer to you question would simply be to set the default value in the form that you're binding this field too, so if they change it or not, there will be a value stored in Field1.

Hope that helps,

Joe P.
Mar 29 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.