Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Assign default value when creating table in ACCESS 2003

Posted on 2009-07-09
10
Medium Priority
?
384 Views
Last Modified: 2013-11-25
Is there a way to create a default value for a column when creating a table in ACCESS 2003?  the only documentation I can find indicates to use the ALTER TABLE statement, but is there a way to simply assign it when first creating the table?  I want the Match column to default to NO.  Also, is there a way to tell the process this should also be a checkbox, which by default is no?
strCreateTable = "CREATE TABLE tblTEMPWeeklyApps (Campaign_ID Integer, SSN Text(12), " & _
    "Booked Integer, Approved Integer, AppDate Date, Age Integer, " & _
    "Reference Text(20), AddrType Integer, DNIS Text(10), AppEID Text(20), " & _
    "Match Bit DEFAULT 'No')"

Open in new window

0
Comment
Question by:ssmith94015
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
10 Comments
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 400 total points
ID: 24816119
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 1600 total points
ID: 24816295
after you create the table you need more code to set the values properties

dim db as dao.database, fd as dao.field, pt as dao.property

strCreateTable = "CREATE TABLE tblTEMPWeeklyApps (Campaign_ID Integer, SSN Text(12), " & _
    "Booked Integer, Approved Integer, AppDate Date, Age Integer, " & _
    "Reference Text(20), AddrType Integer, DNIS Text(10), AppEID Text(20), " & _
    "Match Bit)"

db.execute strCreateTable

Set fd = db.TableDefs("tblTEMPWeeklyApps").Fields("Match")
    fd.DefaultValue = 0
Set pt = fd.CreateProperty("DisplayControl", dbInteger, 106)
    db.TableDefs("tblTEMPWeeklyApps").Fields("Match").Properties.Append pt
0
 

Author Comment

by:ssmith94015
ID: 24816942
I was afraid I was stuck with the ALTER TABLE so that is the route and simplest.
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 

Author Comment

by:ssmith94015
ID: 24816962
Capricorn, yours was a way to do it, but more complicated than what I needed.  But thank you.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 24816972
what about
< Also, is there a way to tell the process this should also be a checkbox>
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 24817000
i don't think it is fair that you will select a suggestion that only fulfills part of your requirement when there is  a complete solution offered.
0
 

Author Comment

by:ssmith94015
ID: 24818316
OH MY GOSH, I completely missed that.  You are so correct, I will contact Adminiistration here and get some points moved.  
0
 

Author Comment

by:ssmith94015
ID: 24818354
Cap, I have sent a request for attention and am requesting 400 points to be moved to you.  I am so very sorry, it has been a long continuous day-night-day and I missed what you were telling me.  Your response was the complete answer and does work but in the time alloted to get this out the door I did use the ALTER statement.
0
 

Author Closing Comment

by:ssmith94015
ID: 31601735
Thank you both and Cap, I again apologize as your works and is complete.  To be fair,  I did give points to DatabaseMX as that was the route I took at the time.
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question