Field Default Values

  • Thread starter Thread starter Aaron Smith
  • Start date Start date
A

Aaron Smith

How do I set field default values at runtime? Say I want a check box
that is bound to a boolean field to default to false for a certain set
of criteria, and then true for others? I also need to do this with other
fields, not just boolean....

Thanks,
Aaron
 
Aaron,

I think that you have to explain something more what is for you the default
value to get an answer.

You can set everything by instance in the load event before a page is
loaded.

Cor
 
When a new record is created, I want the values of the fields (And
associated bound controls) to be filled with a default value. Not on the
loading of a form, on the creation of a new record (row).. I need to do
this in both a DataGrid and various bound controls on a form..

Example, I have a datagrid with County Code, Description, and a Resident
Check box.. If they add a new row I want the resident check box
defaulted to false, instead of null. Then If I have a datagrid that has
numerous fields on it, and one of those is a fee that is stored
elsewhere in the program, I want to be able to put that default fee into
that fee column..

Cor said:
Aaron,

I think that you have to explain something more what is for you the default
value to get an answer.

You can set everything by instance in the load event before a page is
loaded.

Cor
 
Also, I want this done before they start to enter any data into the row,
not after the row has been attempted to save.

Aaron said:
When a new record is created, I want the values of the fields (And
associated bound controls) to be filled with a default value. Not on the
loading of a form, on the creation of a new record (row).. I need to do
this in both a DataGrid and various bound controls on a form..

Example, I have a datagrid with County Code, Description, and a Resident
Check box.. If they add a new row I want the resident check box
defaulted to false, instead of null. Then If I have a datagrid that has
numerous fields on it, and one of those is a fee that is stored
elsewhere in the program, I want to be able to put that default fee into
that fee column..
 
You should be able to use the defaultvalue of the Column object from the
table.

Table.Columns(0).DefaultValue = False

So just grab the Table that is bound to the datagrid and set all the default
values you need set.

Hope it helps.
Chris

Aaron Smith said:
When a new record is created, I want the values of the fields (And
associated bound controls) to be filled with a default value. Not on the
loading of a form, on the creation of a new record (row).. I need to do
this in both a DataGrid and various bound controls on a form..

Example, I have a datagrid with County Code, Description, and a Resident
Check box.. If they add a new row I want the resident check box defaulted
to false, instead of null. Then If I have a datagrid that has numerous
fields on it, and one of those is a fee that is stored elsewhere in the
program, I want to be able to put that default fee into that fee column..
 
Chris,

About 10 seconds ago I stepped into the column changing event just to
poke around and saw a defaultvalue property... That is exactly what I
need. I can modify this when I need to change what the default value is.
I hate not knowing more in depth about this stuff.. Makes me search for
hours to find something so simple.

Thanks for the help.
Aaron
You should be able to use the defaultvalue of the Column object from the
table.

Table.Columns(0).DefaultValue = False

So just grab the Table that is bound to the datagrid and set all the default
values you need set.

Hope it helps.
Chris
 
That's why we are here...

Chris

Enjoy the learning, it's what makes the job worth doing


Aaron Smith said:
Chris,

About 10 seconds ago I stepped into the column changing event just to poke
around and saw a defaultvalue property... That is exactly what I need. I
can modify this when I need to change what the default value is. I hate
not knowing more in depth about this stuff.. Makes me search for hours to
find something so simple.

Thanks for the help.
Aaron
 
And I definately appreciate all of you people for being here. It keeps
some hair left on top of my head. :D
That's why we are here...

Chris

Enjoy the learning, it's what makes the job worth doing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top