Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

default value of a field in RST

Status
Not open for further replies.

nnmmss

Programmer
Sep 7, 2004
123
IR
I am defining a recordset like this

Set rstDG = New ADODB.Recordset

rstDG.Fields.Append "Id", adDouble
rstDG.Fields.Append "GoodsName", adVarChar, 255
rstDG.Fields.Append "GoodsId", adDouble
rstDG.Fields.Append "TypDesig", adVarChar, 255
rstDG.Fields.Append "TypeId", adDouble
rstDG.Fields.Append "TechCode", adVarChar, 255
rstDG.Fields.Append "TechId", adDouble
rstDG.Fields.Append "PLDId", adVarChar, 255, , "0"
rstDG.Open

but it gives me this error on line "rstDG.Fields.Append "PLDId", adVarChar, 255, , "0"
"
arguments are the wrong type, or out of acceptable range or in conflict with one another

i want the Field PLDId has a default value of "0", what is wrong with it?
 
The simple answer is that the format of the append method is
Code:
fields.Append Name, Type, DefinedSize, Attrib
So you're getting the error because you have added a fifth (and undefined) parameter.

Near as I can determine, only a field in a table (i.e. one that has been added to a tables collection in a database) has a default property. Fields in recordsets do not. I guess that sorta makes sense because default values are applied when data are written to the database and, with a disconnected recordset like this, there is no database.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top