Change 'Default Value' of many fields in many tables at one time

Hi. I have over 20 tables with many fields in each that are Currency
fields. Every one has a Default Value of 0, which gives every new
record I create hundreds of $0 values. Is there a way to remove this
Default Value for all these fields and tables at one time? or will I
have to finish out the school of hard knocks one field at a time?

Many thanks for your continued help!
Greg.
g_k_harrison [ Mi, 09 April 2008 17:28 ] [ ID #1938858 ]

Re: Change 'Default Value' of many fields in many tables at one time

On Apr 9, 8:28=A0am, g_k_harri... [at] yahoo.com wrote:
> Hi. I have over 20 tables with many fields in each that are Currency
> fields. Every one has a Default Value of 0, which gives every new
> record I create hundreds of $0 values. Is there a way to remove this
> Default Value for all these fields and tables at one time? or will I
> have to finish out the school of hard knocks one field at a time?
>
> Many thanks for your continued help!
> Greg.

First, go to the table definitions and remove the default values for
each field.

Next, you will have to create an update query for each table that
updates all currency fields with values =3D 0 to a desireable value,
like NULL.

UPDATE tblAny1 SET
Field1 =3D NULL
WHERE Field1 =3D 0

Execute this query after changing the field names for each field in
the table. Repeat this process for each table.
Technolust [ Mi, 09 April 2008 19:49 ] [ ID #1938865 ]

Re: Change 'Default Value' of many fields in many tables at one time

On Apr 9, 1:49=A0pm, Technolust <queenskni... [at] technologist.com> wrote:
> On Apr 9, 8:28=A0am, g_k_harri... [at] yahoo.com wrote:
>
> > Hi. I have over 20 tables with many fields in each that are Currency
> > fields. Every one has a Default Value of 0, which gives every new
> > record I create hundreds of $0 values. Is there a way to remove this
> > Default Value for all these fields and tables at one time? or will I
> > have to finish out the school of hard knocks one field at a time?
>
> > Many thanks for your continued help!
> > Greg.
>
> First, go to the table definitions and remove the default values for
> each field.
>
> Next, you will have to create an update query for each table that
> updates all currency fields with values =3D 0 to a desireable value,
> like NULL.
>
> UPDATE tblAny1 SET
> =A0 =A0 =A0Field1 =3D NULL
> =A0 =A0 =A0WHERE Field1 =3D 0
>
> Execute this query after changing the field names for each field in
> the table. =A0Repeat this process for each table.

I dont THINK you have to change the table structure in order to change
the values in existing records. You can merely run the UPDATE query
for each field/table. The change/removal of the default should only
affect new records added w/o a value specified for the fioeld(s) in
question.
frogsteaks [ Mi, 09 April 2008 20:23 ] [ ID #1938866 ]

Re: Change 'Default Value' of many fields in many tables at one time

On Apr 9, 12:49=A0pm, Technolust <queenskni... [at] technologist.com> wrote:
> On Apr 9, 8:28=A0am, g_k_harri... [at] yahoo.com wrote:
>
> > Hi. I have over 20 tables with many fields in each that are Currency
> > fields. Every one has a Default Value of 0, which gives every new
> > record I create hundreds of $0 values. Is there a way to remove this
> > Default Value for all these fields and tables at one time? or will I
> > have to finish out the school of hard knocks one field at a time?
>
> > Many thanks for your continued help!
> > Greg.
>
> First, go to the table definitions and remove the default values for
> each field.
>
> Next, you will have to create an update query for each table that
> updates all currency fields with values =3D 0 to a desireable value,
> like NULL.
>
> UPDATE tblAny1 SET
> =A0 =A0 =A0Field1 =3D NULL
> =A0 =A0 =A0WHERE Field1 =3D 0
>
> Execute this query after changing the field names for each field in
> the table. =A0Repeat this process for each table.

Thank you for that suggestion!
g_k_harrison [ Mi, 09 April 2008 23:13 ] [ ID #1938886 ]

Re: Change 'Default Value' of many fields in many tables at one time

g_k_harrison [at] yahoo.com wrote:

>Hi. I have over 20 tables with many fields in each that are Currency
>fields. Every one has a Default Value of 0, which gives every new
>record I create hundreds of $0 values. Is there a way to remove this
>Default Value for all these fields and tables at one time? or will I
>have to finish out the school of hard knocks one field at a time?


You could write a utility procedure to make those design
changes. Loop through the TableDefs collection (skipping
the system and other table you do not want to change). Loop
through each table's Fields collection checking the data
type for dbCurrency. Then you can set the DefaultValue
property to ""

A general air code outline of DAO code could be something
like:

For Each tdf In db.TableDefs
If tdf.Name Like "MSYS*" _
Or tdf.Name = "some odd table" _
Or . . . Then Exit For
For Each fld In tdf.Fields
If fld.Type = dbCurrency Then
fld.Properties!DefaultValue = ""
End If
Next fld
Next tdf

If any currency field does not have a default set, then use
error handling to ignore the missing property error.

--
Marsh
Marshall Barton [ Fr, 11 April 2008 01:51 ] [ ID #1940352 ]
Datenbanken » comp.databases.ms-access » Change 'Default Value' of many fields in many tables at one time

Vorheriges Thema: Using an Access recordset to update SQL backend
Nächstes Thema: Resetting RunningSum OverAll