Oh, that was scarey. that didn't come out the same way I wrote it.
Thanks Anyway.
Ok
"Dominic Vella" <do***********@ optusnet.com.au wrote in message
news:47******** *************** @news.optusnet. com.au...
Yes, I have been using TableDef. It's just now a 2 step process that has
more variables in it.
I was developing a self updating database package, and it was simpler
using SQL statements. Now my Update Table will require table names and
fieldnames to make it work. Check out the difference
Preferred method - tblUpdate has only one field
------------------
cnn.Execute tblUpdate.updat e_sql
NonPrefered method - tblUpdate has 5 fields
---------------------
Const cUpdateSQL =1
Const cUpdateDefaultS tring = 2
Const cUpdateDefaultN umber = 3
Select Case tblUpdate.Type
Case 1: cnn.execute tblUpdate.updat e_sql
Case 2
cnn.TablesDef( tblUpdate.updat e_table ).Field(
tblUpdate.updat e_field ).default( tblUpdate.updat e_value_string )
Case 3 cnn.TablesDef( tblUpdate.updat e_table ).Field(
tblUpdate.updat e_field ).default( tblUpdate.updat e_value_number )
End Select
etc.... and I'd have to do it twice, first time to run the SQL to create
the field, and again to set the default It's horrible, but seems
necessary.
Mind you, it's not all bad as I could use something like this (Tables
andFields) in the future as I modify Forms and Controls, Commands
andArguments , etc. Can't do those with SQL statements.
Thanks anyway
Dominic
"Allen Browne" <Al*********@Se eSig.Invalidwro te in
messagenews:47* *************** *******@per-qv1-newsreader-01.iinet.net.au ...>
Dominic, it looks like DEFAULT works with CREATE TABLE executed under
ADO,but not with ALTER TABLE.>Much simpler to use DAO to set the
DefaultProperty of the Field in theTableDef anyway.>--Allen Browne -
Microsoft MVP. Perth, Western AustraliaTips for Access users -
http://allenbrowne.com/tips.htmlReply to group, rather than allenbrowne at
mvps dot org.>"Dominic Vella" <do***********@ optusnet.com.au wrote in
messagenews:47* *************** *******@news.op tusnet.com.au.. .>Thanks for
the reply.>>>It didn't work as in I received a 'Syntax Error in ALTER
TABLEstatement. ' Error>>>I decided it could have been because I'm using
DAO instead of ABODB, so Itried this:>>> Dim cnn As New
ADODB.Connectio n> Dim rst As New ADODB.Recordset >>> ' Open the
connection.> Set cnn = New ADODB.Connectio n> With cnn> .Provider
= "Microsoft.Jet. OLEDB.4.0"> .Open CurrentProject. path &
"\data_be.m db"> End With>>> cnn.Execute "ALTER TABLE [tblStudent] ADD
COLUMN[student_accommo dation] YESNO True;">>> cnn.Close> Set cnn =
Nothing>>>I had to leave the word DEFAULT out as it caused it's own
'Databasedefaul t definition' error.>Still, using True, -1 and 1 created
the field but did not set the defaultvalue. Using .T. was definately no
good.>I think it's a quirk with Logical fields, other field types don't
haveany problems setting the default (that I found so far). This is
frustratingthou gh.>>>Dominic>> >"Allen Browne"
<Al*********@Se eSig.Invalidwro te in
messagenews:47* *************** *******@per-qv1-newsreader-01.iinet.net.au ...>>>
Try something like this:>>>>> strSql = "ALTER TABLE tblStudent ADD
COLUMN student_accommo dationYESNO DEFAULT True;">>>
CurrentProject. Connection.Exec ute strSql>>>>>The important thing is
executing the string with ADO code.>>>>>-1 should also work.>>>>>-->>>
Allen Browne - Microsoft MVP. Perth, Western Australia>>Tips for Access
users - http://allenbrowne.com/tips.html>>Repl y to group, rather than
allenbrowne at mvps dot org.>>>>>"Domin ic Vella"
<do***********@ optusnet.com.au wrote in message>>>
news:47******** *************** @news.optusnet. com.au...>>>>I am using
MS-Access2000. I can't seem to set the default values forLogical type
fields. I start with>>> Dim dbsTmp As Object ' I think it's
DAO.Database>>> Set dbsTmp = DBEngine.OpenDa tabase(CurrentP roject.path
&"\data_be.mdb" )>>>>>>>and then use the following to run my SQL
ststement>>>>
dbsTmp.Execute> >>----------------------------------------------------->>>>
Something like this SQL statement works:>>>"ALTER TABLE tblStudent ADD
COLUMN student_number long NULL">>>>>>>But all of these SQL statements
don't seem to work>>>"ALTER TABLE tblStudent ADD COLUMN
student_accommo dation logical -1">>>"ALTER TABLE tblStudent ADD COLUMN
student_accommo dation logical 1">>>"ALTER TABLE tblStudent ADD COLUMN
student_accommo dation logical TRUE">>>"ALTER TABLE tblStudent ADD COLUMN
student_accommo dation logical
..T.">>>>>>>------------------------------------------------------>>>Can
anyone tell me how to set the default value for a logical field?>>>>>>>>
>