473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

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
1 2820
PianoMan64
374 Expert 256MB
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

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

Similar topics

2
by: Randy Jackson | last post by:
First of all, I apologize in advance if this is covered somewhere in a FAQ. I did a Google search, but really couldn't find anything. I'm having a problem with a simple select query. I've got...
1
by: Luki | last post by:
Hello i'm stuck on a seemingly small problem. i'm trying get the default value of a column in a table on a MS SQL Server. i try to use sp_columns. eg sp_columns @table_name = 'addresses' in...
1
by: Programmer | last post by:
Hi All Here is my problem I'm using a SQLDataAdapter and DataSet I use the method FillSchema(myDataset, SchemaType.Source) The problem is that when i Check the default Values of the Dataset...
2
by: Terry Bickle | last post by:
Please forgive me for using the wrong term here or there. I'm an old Excel 4 macro guy who didn't convert to VB and I'm tinkering with an Access 2000 DB. I'm sure there is a simple Access 101...
2
by: Bob | last post by:
I have a CreatedOn field , datetime, which has GetDate() as the default value in SQL server 2000 table. When I create a new record in the table itself in enterprise manager, the field gets...
2
by: mukesh | last post by:
Can we use expression in default value for a table field for example – IIf(Table-1.field-1=table-2 . field-1, table-1.field-2, 0) Interpretation – If field-1 of table -1 is like/equal to...
13
by: kev | last post by:
Hi all, I have created a database for equipments. I have a form to register the equipment meaning filling in all the particulars (ID, serial, type, location etc). I have two buttons at the end...
7
by: rockdc1981 | last post by:
i have audit trail module using this code... Option Compare Database Option Explicit Public Function AuditTrail() On Error GoTo Err_Audit_Trail 'ACC2000: How to Create an Audit Trail...
21
by: giandeo | last post by:
Hello Experts. Is it possible to retrieve the value from a populated pull down menu from a database and then use that value to access the same database to get the related fields. Example: ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.