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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I set a default value in a table 1

Status
Not open for further replies.

Razor1

IS-IT--Management
Nov 21, 2002
81
US
I am creating a table using VBA and I need to set a default value for the fields.

Any ideas on how to accomplish this?

Thanks in advance.



Razor1
 
What code are you using to create the table?

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
One way would be as so:
Code:
Dim MyDB As Database
Set MyDB = CurrentDb()

MyDB.Execute "CREATE TABLE TestTable (Col1 TEXT(50), Col2 TEXT(50))"

MyDB.Close

CurrentDb.TableDefs("TestTable").Fields("Col1").DefaultValue = "HarleyQuinn
Hope this helps

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Thanks worked well.


Razor1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top