How do I change table field definition via code?

D

Damon Heron

I have a date field in a linked table that is set to required =yes. I want
to change it to required =no. I want to use code because this will be part
of an update of an existing front end for several locations.
Thanks in advance for any ideas.

Damon
 
T

Tony Toews [MVP]

Damon Heron said:
I have a date field in a linked table that is set to required =yes. I want
to change it to required =no. I want to use code because this will be part
of an update of an existing front end for several locations.

Use the Compare'em utility on a before and after copy. Granted it's
overkill for what you want but it works and could be very useful in
the future.

Compare'Em
http://home.gci.net/~mike-noel/CompareEM-LITE/CompareEM.htm

Otherwise I'd have to go digging through my code to figure it out.

I also keep a version number in a table in the BE so I can run
whatever code is required just to upgrade the BE to the version
required for the FE.

In your case I'd check to see if that table exists first. If not then
use code to create the table and a field and then use an INSERT query
to create the version # record.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
D

Damon Heron

You are right, it is overkill. I was hoping for some simple DAO code that
alters the required field.
I have searched the help file and googled with no luck. Can it be done?

Damon
 
P

Paul Shapiro

If you're using DAO, it can be as simple as:
Currentdb.tabledefs("myTableName").fields("myFieldName").Required =
false
 
D

Damon Heron

Thanks to all who helped me see the light! Access newsgroups are so cool!
I ended up using a bit from each and, of course, complicated everything,
but it seems to be working fine.
Thanks again,
Damon
 

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

Top