DAO and Delphi -> Update MS Access database structure

Hi,

When I open a table in MS Access (in designview) and add a boolean field, it will have as it's property:
Fieldname = 'Test1'
Fieldtype = 'Yes/No'
Format = 'Yes/No'      (= automatically filled)
Format can be changed into Yes/No, True/False and On/Off

The statement below is not adding the Format-property of the boolean field.
ALTER TABLE FracturenUIT ADD COLUMN IsCorrect YesNo
Fieldname = 'Test1'
Fieldtype = 'Yes/No'
Format = <empty>

I seems that DAO has access to the format-property. I already imported the DAO 3.6 Objects library into my project, but I don't know how to use DAO to:
1. Open MS Access database that is password protected
2. Add or alter a table
3. Alter fieldname properties (especially property: FORMAT)

Bye the way: I just need DAO to make changes to the database structure (including the fieldproperties). (For accessing my data I use ADO).

Please give me some samples on different fieldtypes (f.e. Boolean, Text, Float, Memo)

Thanks in advance for your help,
Regards, Stef
Stef MerlijnDeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
run this function to create a table with data types

Function CreateTableDDL()
Dim sql As String
sql = "CREATE TABLE TestAllTypes "
sql = sql & "( "
sql = sql & "      MyText       TEXT(50), "
sql = sql & "      MyMemo       MEMO, "
sql = sql & "      MyByte       BYTE, "
sql = sql & "      MyInteger    INTEGER, "
sql = sql & "      MyLong       LONG, "
sql = sql & "      MyAutoNumber COUNTER, "
sql = sql & "      MySingle     SINGLE, "
sql = sql & "      MyDouble     DOUBLE, "
sql = sql & "      MyCurrency   CURRENCY, "
sql = sql & "      MyReplicaID  GUID, "
sql = sql & "      MyDateTime   DATETIME, "
sql = sql & "      MyYesNo      YESNO, "
sql = sql & "      MyOleObject  LONGBINARY, "
sql = sql & "      MyBinary     BINARY(50) "
sql = sql & ")"
CurrentDb.Execute sql
End Function

0
Stef MerlijnDeveloperAuthor Commented:
Thank you Capricorn1:
I looks as if your code is Visual Basic and I'm using Delphi.
Also I don't see anything about the Format-property?
0
rockiroadsCommented:
As far as I know, u cant edit the format properties via sql
It can be done using DAO/VBA but I do not know how to do this in Delphi

sample code to add tables using DAO can be found here http://www.scalabium.com/faq/dct0111.htm

to open password protected databases, u could possibly try passing in a password here (see code from link provided)

db := access.OpenDatabase(yourDatabaseName);

one of the arguments might have something which allows passing of passwords.

As I dont have Delphi, I cant confirm this but you can play around
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Rey Obrero (Capricorn1)Commented:
Delphiwizard,
sorry, thoght you want to do it in Access VBA
0
ziolkoCommented:
i think that it doesn't matter if you choose yes/no, true/false, on/off access stores value in the same way
you just choose how access application will interpret value of boolean field

ziolko.
0
Eddie ShipmanAll-around developerCommented:
See this article on using ADOX to create your database/tables:
http://delphi.about.com/od/database/l/aa072401a.htm
0
Stef MerlijnDeveloperAuthor Commented:
ADOX doesn't support changing the field's Format-property.
Therefor I need to do the database updates with DAO.
0
Stef MerlijnDeveloperAuthor Commented:
Thank you all for your help.
I have bought the DAO componentsuite of Scalabium. This is giving me all the stuff I need.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.