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!

set a default value in form 1

Status
Not open for further replies.

yellowke

Programmer
Nov 5, 2002
48
BE
hi,

I have a form.
When I press the add button I want a default value in some fields.
e.g. I have a field called datum11 and I want the default value to be : ------
What code do I have to set in the click event of the add button?

Maybe it's interesting to know that the form is based on a single table and because of that every field has a control source. e.g. controlsource of datum11: u218sub8.datum1.

It's probably something very simpel but I will be very happy if I know how to do this.

Tnx in advance
 
yellowke

Are you usind a database to "hold" your table? If so you can specify a default value in the database by modifying the table, selecting the field you want to set a default for and in the right-hand corner, you can specify the default value.

If you are not using a database, you would have to code it yourself, in the add record button something like:
INSERT INTO myTable (name) VALUES ("____")

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Now I have a single table.
But if I put the table in a database, what do I have to change on the form to make it work with the database instead of the single table? Maybe this can be done without a lot of work?

I used the wizard for the form and the standard buttons it produced (prev,next,bottom,top,add,...)

selecting the field you want to set a default for and in the right-hand corner, you can specify the default value.
--> Is this in the add property??

Tnx
Yellowke
 
selecting the field you want to set a default for and in the right-hand corner, you can specify the default value.
--> Is this in the add property??


No, this would be when you modify the database.Modiy the database that contains you table. Modify the table itself, and you will see a box that say "Default value". Set that to whatever you want. And when you are in your form and click add, the "default value" will appear in that field.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top