Logical Default
am 16.01.2008 21:59:28 von Dominic Vella
I am using MS-Access2000. I can't seem to set the default values for Logical
type fields. I start with
Dim dbsTmp As Object ' I think it's DAO.Database
Set dbsTmp = DBEngine.OpenDatabase(CurrentProject.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_accommodation logical -1"
"ALTER TABLE tblStudent ADD COLUMN student_accommodation logical 1"
"ALTER TABLE tblStudent ADD COLUMN student_accommodation logical TRUE"
"ALTER TABLE tblStudent ADD COLUMN student_accommodation logical .T."
------------------------------------------------------
Can anyone tell me how to set the default value for a logical field?
Thanks
Dominic
Re: Logical Default
am 17.01.2008 01:47:12 von Allen Browne
Try something like this:
strSql = "ALTER TABLE tblStudent ADD COLUMN student_accommodation YESNO
DEFAULT True;"
CurrentProject.Connection.Execute 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
Reply to group, rather than allenbrowne at mvps dot org.
"Dominic Vella" wrote in message
news:478e702b$0$13262$afc38c87@news.optusnet.com.au...
>I am using MS-Access2000. I can't seem to set the default values for
>Logical type fields. I start with
> Dim dbsTmp As Object ' I think it's DAO.Database
> Set dbsTmp = DBEngine.OpenDatabase(CurrentProject.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_accommodation logical -1"
> "ALTER TABLE tblStudent ADD COLUMN student_accommodation logical 1"
> "ALTER TABLE tblStudent ADD COLUMN student_accommodation logical TRUE"
> "ALTER TABLE tblStudent ADD COLUMN student_accommodation logical .T."
>
> ------------------------------------------------------
> Can anyone tell me how to set the default value for a logical field?
Re: Logical Default
am 17.01.2008 04:10:28 von Dominic Vella
Thanks for the reply.
It didn't work as in I received a 'Syntax Error in ALTER TABLE statement.'
Error
I decided it could have been because I'm using DAO instead of ABODB, so I
tried this:
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
' Open the connection.
Set cnn = New ADODB.Connection
With cnn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open CurrentProject.path & "\data_be.mdb"
End With
cnn.Execute "ALTER TABLE [tblStudent] ADD COLUMN [student_accommodation]
YESNO True;"
cnn.Close
Set cnn = Nothing
I had to leave the word DEFAULT out as it caused it's own 'Database default
definition' error.
Still, using True, -1 and 1 created the field but did not set the default
value. Using .T. was definately no good.
I think it's a quirk with Logical fields, other field types don't have any
problems setting the default (that I found so far). This is frustrating
though.
Dominic
"Allen Browne" wrote in message
news:478ea592$0$30868$5a62ac22@per-qv1-newsreader-01.iinet.n et.au...
> Try something like this:
>
> strSql = "ALTER TABLE tblStudent ADD COLUMN student_accommodation YESNO
> DEFAULT True;"
> CurrentProject.Connection.Execute 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
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "Dominic Vella" wrote in message
> news:478e702b$0$13262$afc38c87@news.optusnet.com.au...
>>I am using MS-Access2000. I can't seem to set the default values for
>>Logical type fields. I start with
>> Dim dbsTmp As Object ' I think it's DAO.Database
>> Set dbsTmp = DBEngine.OpenDatabase(CurrentProject.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_accommodation logical -1"
>> "ALTER TABLE tblStudent ADD COLUMN student_accommodation logical 1"
>> "ALTER TABLE tblStudent ADD COLUMN student_accommodation logical TRUE"
>> "ALTER TABLE tblStudent ADD COLUMN student_accommodation logical .T."
>>
>> ------------------------------------------------------
>> Can anyone tell me how to set the default value for a logical field?
>
Re: Logical Default
am 17.01.2008 10:47:44 von Allen Browne
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 the
TableDef anyway.
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Dominic Vella" wrote in message
news:478ec723$0$10472$afc38c87@news.optusnet.com.au...
> Thanks for the reply.
>
> It didn't work as in I received a 'Syntax Error in ALTER TABLE statement.'
> Error
>
> I decided it could have been because I'm using DAO instead of ABODB, so I
> tried this:
>
> Dim cnn As New ADODB.Connection
> Dim rst As New ADODB.Recordset
>
> ' Open the connection.
> Set cnn = New ADODB.Connection
> With cnn
> .Provider = "Microsoft.Jet.OLEDB.4.0"
> .Open CurrentProject.path & "\data_be.mdb"
> End With
>
> cnn.Execute "ALTER TABLE [tblStudent] ADD COLUMN
> [student_accommodation] YESNO True;"
>
> cnn.Close
> Set cnn = Nothing
>
> I had to leave the word DEFAULT out as it caused it's own 'Database
> default definition' error.
> Still, using True, -1 and 1 created the field but did not set the default
> value. Using .T. was definately no good.
> I think it's a quirk with Logical fields, other field types don't have any
> problems setting the default (that I found so far). This is frustrating
> though.
>
> Dominic
>
> "Allen Browne" wrote in message
> news:478ea592$0$30868$5a62ac22@per-qv1-newsreader-01.iinet.n et.au...
>> Try something like this:
>>
>> strSql = "ALTER TABLE tblStudent ADD COLUMN student_accommodation
>> YESNO DEFAULT True;"
>> CurrentProject.Connection.Execute 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
>> Reply to group, rather than allenbrowne at mvps dot org.
>>
>> "Dominic Vella" wrote in message
>> news:478e702b$0$13262$afc38c87@news.optusnet.com.au...
>>>I am using MS-Access2000. I can't seem to set the default values for
>>>Logical type fields. I start with
>>> Dim dbsTmp As Object ' I think it's DAO.Database
>>> Set dbsTmp = DBEngine.OpenDatabase(CurrentProject.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_accommodation logical -1"
>>> "ALTER TABLE tblStudent ADD COLUMN student_accommodation logical 1"
>>> "ALTER TABLE tblStudent ADD COLUMN student_accommodation logical TRUE"
>>> "ALTER TABLE tblStudent ADD COLUMN student_accommodation logical .T."
>>>
>>> ------------------------------------------------------
>>> Can anyone tell me how to set the default value for a logical field?
>>
>
>
Re: Logical Default
am 17.01.2008 11:26:21 von Dominic Vella
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.update_sql
NonPrefered method - tblUpdate has 5 fields
---------------------
Const cUpdateSQL =1
Const cUpdateDefaultString = 2
Const cUpdateDefaultNumber = 3
Select Case tblUpdate.Type
Case 1: cnn.execute tblUpdate.update_sql
Case 2
cnn.TablesDef(tblUpdate.update_table).Field(tblUpdate.update _field).default(tblUpdate.update_value_string )Case 3 cnn.TablesDef(tblUpdate.update_table).Field(tblUpdate.update _field).default( tblUpdate.update_value_number )End Selectetc.... and I'd have to do it twice, first time to run the SQL to create thefield, 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 anywayDominic"Allen Browne" wrote in messagenews:478f2444$0$30848$5a62ac22@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 Australia> Tips for Access users - http://allenbrowne.com/tips.html> Reply to group, rather than allenbrowne at mvps dot org.>> "Dominic Vella" wrote in message> news:478ec723$0$10472$afc38c87@news.optusnet.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.Connection>> Dim rst As New ADODB.Recordset>>>> ' Open the connection.>> Set cnn = New ADODB.Connection>> With cnn>> .Provider = "Microsoft.Jet.OLEDB.4.0">> .Open CurrentProject.path & "\data_be.mdb">> End With>>>> cnn.Execute "ALTER TABLE [tblStudent] ADD COLUMN[student_accommodation] YESNO True;">>>> cnn.Close>> Set cnn = Nothing>>>> I had to leave the word DEFAULT out as it caused it's own 'Databasedefault 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 frustratingthough.>>>> Dominic>>>> "Allen Browne" wrote in messagenews:478ea592$0$30868$5a62ac22@per-qv1-newsreader-01. iinet.net.au...>>> Try something like this:>>>>>> strSql = "ALTER TABLE tblStudent ADD COLUMN student_accommodationYESNO DEFAULT True;">>> CurrentProject.Connection.Execute 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>>> Reply to group, rather than allenbrowne at mvps dot org.>>>>>> "Dominic Vella" wrote in message>>> news:478e702b$0$13262$afc38c87@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.OpenDatabase(CurrentProject.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_accommodation logical -1">>>> "ALTER TABLE tblStudent ADD COLUMN student_accommodation logical 1">>>> "ALTER TABLE tblStudent ADD COLUMN student_accommodation logical TRUE">>>> "ALTER TABLE tblStudent ADD COLUMN student_accommodation logical .T.">>>>>>>> ------------------------------------------------------>>>> Can anyone tell me how to set the default value for a logical field?>>>>>>>>
Re: Logical Default
am 17.01.2008 11:38:39 von Dominic Vella
Oh, that was scarey. that didn't come out the same way I wrote it.
Thanks Anyway.
Ok
"Dominic Vella" wrote in message
news:478f2d49$0$13959$afc38c87@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.update_sql
>
> NonPrefered method - tblUpdate has 5 fields
> ---------------------
> Const cUpdateSQL =1
> Const cUpdateDefaultString = 2
> Const cUpdateDefaultNumber = 3
>
> Select Case tblUpdate.Type
> Case 1: cnn.execute tblUpdate.update_sql
> Case 2
> cnn.TablesDef( tblUpdate.update_table ).Field(
> tblUpdate.update_field ).default( tblUpdate.update_value_string )
> Case 3 cnn.TablesDef( tblUpdate.update_table ).Field(
> tblUpdate.update_field ).default( tblUpdate.update_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" wrote in
messagenews:478f2444$0$30848$5a62ac22@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 Australia> Tips for Access users -
http://allenbrowne.com/tips.html> Reply to group, rather than allenbrowne at
mvps dot org.>> "Dominic Vella" wrote in
message> news:478ec723$0$10472$afc38c87@news.optusnet.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.Connection>> Dim rst As New ADODB.Recordset>>>> ' Open the
connection.>> Set cnn = New ADODB.Connection>> With cnn>> .Provider
= "Microsoft.Jet.OLEDB.4.0">> .Open CurrentProject.path &
"\data_be.mdb">> End With>>>> cnn.Execute "ALTER TABLE [tblStudent] ADD
COLUMN[student_accommodation] YESNO True;">>>> cnn.Close>> Set cnn =
Nothing>>>> I had to leave the word DEFAULT out as it caused it's own
'Databasedefault 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
frustratingthough.>>>> Dominic>>>> "Allen Browne"
wrote in
messagenews:478ea592$0$30868$5a62ac22@per-qv1-newsreader-01. iinet.net.au...>>>
Try something like this:>>>>>> strSql = "ALTER TABLE tblStudent ADD
COLUMN student_accommodationYESNO DEFAULT True;">>>
CurrentProject.Connection.Execute 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>>> Reply to group, rather than
allenbrowne at mvps dot org.>>>>>> "Dominic Vella"
wrote in message>>>
news:478e702b$0$13262$afc38c87@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.OpenDatabase(CurrentProject.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_accommodation logical -1">>>> "ALTER TABLE tblStudent ADD COLUMN
student_accommodation logical 1">>>> "ALTER TABLE tblStudent ADD COLUMN
student_accommodation logical TRUE">>>> "ALTER TABLE tblStudent ADD COLUMN
student_accommodation logical
..T.">>>>>>>> ------------------------------------------------------>>>> Can
anyone tell me how to set the default value for a logical field?>>>>>>>>
>
Re: Logical Default
am 17.01.2008 12:00:00 von Lye Fairfield
"Allen Browne" wrote in
news:478f2444$0$30848$5a62ac22@per-qv1-newsreader-01.iinet.n et.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 the
> TableDef anyway.
This works:
CurrentProject.Connection.Execute "ALTER TABLE Table1 ADD COLUMN
[Sudent_Acommodation] YesNo DEFAULT Yes"
--
lyle fairfield
In ancient times Ulysses had to outwit the sirens, who had the power to
charm by their song all sailors who heard them, so that the mariners were
compelled to cast themselves into the sea to their destruction.
Today, he would have to deal with (free) Aim-Mail.
Re: Logical Default
am 17.01.2008 12:01:18 von Lye Fairfield
"Dominic Vella" wrote in
news:478ec723$0$10472$afc38c87@news.optusnet.com.au:
> Thanks for the reply.
>
> It didn't work as in I received a 'Syntax Error in ALTER TABLE
> statement.' Error
>
> I decided it could have been because I'm using DAO instead of ABODB,
> so I tried this:
>
> Dim cnn As New ADODB.Connection
> Dim rst As New ADODB.Recordset
>
> ' Open the connection.
> Set cnn = New ADODB.Connection
> With cnn
> .Provider = "Microsoft.Jet.OLEDB.4.0"
> .Open CurrentProject.path & "\data_be.mdb"
> End With
>
> cnn.Execute "ALTER TABLE [tblStudent] ADD COLUMN
> [student_accommodation]
> YESNO True;"
>
> cnn.Close
> Set cnn = Nothing
>
> I had to leave the word DEFAULT out as it caused it's own 'Database
> default definition' error.
> Still, using True, -1 and 1 created the field but did not set the
> default value. Using .T. was definately no good.
> I think it's a quirk with Logical fields, other field types don't have
> any problems setting the default (that I found so far). This is
> frustrating though.
This is not frustrating (to me, anyway):
CurrentProject.Connection.Execute "ALTER TABLE Table1 ADD COLUMN
[Sudent_Acommodation] YesNo DEFAULT Yes"
--
lyle fairfield
In ancient times Ulysses had to outwit the sirens, who had the power to
charm by their song all sailors who heard them, so that the mariners were
compelled to cast themselves into the sea to their destruction.
Today, he would have to deal with (free) Aim-Mail.
Re: Logical Default
am 17.01.2008 12:02:53 von Lye Fairfield
"Dominic Vella" wrote in
news:478f2d49$0$13959$afc38c87@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.
Either that or you could try the correct SQL, I suppose.
--
lyle fairfield
In ancient times Ulysses had to outwit the sirens, who had the power to
charm by their song all sailors who heard them, so that the mariners were
compelled to cast themselves into the sea to their destruction.
Today, he would have to deal with (free) Aim-Mail.
Re: Logical Default
am 17.01.2008 12:18:47 von Allen Browne
"lyle fairfield" wrote in message
news:2AGjj.514$2Z1.247@read1.cgocable.net...
> "Dominic Vella" wrote in
> news:478ec723$0$10472$afc38c87@news.optusnet.com.au:
>
> CurrentProject.Connection.Execute "ALTER TABLE Table1
> ADD COLUMN [Sudent_Acommodation] YesNo DEFAULT Yes"
Hi Lyle. I still can't get DEFAULT to work with an existing column, i.e.:
strSql = "ALTER TABLE MyTable ALTER COLUMN MyYesNo DEFAULT Yes;"
CurrentProject.AccessConnection.Execute strSql
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
Re: Logical Default
am 17.01.2008 13:09:44 von Lye Fairfield
"Allen Browne" wrote in
news:478f399c$0$30858$5a62ac22@per-qv1-newsreader-01.iinet.n et.au:
> "lyle fairfield" wrote in message
> news:2AGjj.514$2Z1.247@read1.cgocable.net...
>> "Dominic Vella" wrote in
>> news:478ec723$0$10472$afc38c87@news.optusnet.com.au:
>>
>> CurrentProject.Connection.Execute "ALTER TABLE Table1
>> ADD COLUMN [Sudent_Acommodation] YesNo DEFAULT Yes"
>
> Hi Lyle. I still can't get DEFAULT to work with an existing column,
> i.e.:
>
> strSql = "ALTER TABLE MyTable ALTER COLUMN MyYesNo DEFAULT Yes;"
> CurrentProject.AccessConnection.Execute strSql
Application name Microsoft Access
Version 9.0
Build 6620
I installed this instance just a few weeks ago; I think it's pretty
standard.
Sub temp()
CurrentProject.Connection.Execute "ALTER TABLE Table1 ADD COLUMN
[Student_Acommodation] YesNo DEFAULT Yes" End Sub
Sub temp2()
CurrentProject.Connection.Execute "ALTER TABLE Table1 ALTER COLUMN
[Student_Acommodation] YesNo DEFAULT No" End Sub
Both set the Default for the Boolean Field as indicated, as confirmed in
Design View.
In Datasheet a new record shows as -1 after the first, 0 after the
second.
Table1 has one other field: ID autonumber.
--
lyle fairfield
In ancient times Ulysses had to outwit the sirens, who had the power to
charm by their song all sailors who heard them, so that the mariners
were compelled to cast themselves into the sea to their destruction.
Today, he would have to deal with (free) Aim-Mail.
Re: Logical Default
am 18.01.2008 06:25:04 von Dominic Vella
Yes, that's it. You're a genius, only I'll spell [Sudent_Acommodation] a
little differently
Dom
"lyle fairfield" wrote in message
news:cAHjj.516$2Z1.435@read1.cgocable.net...
> "Allen Browne" wrote in
> news:478f399c$0$30858$5a62ac22@per-qv1-newsreader-01.iinet.n et.au:
>
>> "lyle fairfield" wrote in message
>> news:2AGjj.514$2Z1.247@read1.cgocable.net...
>>> "Dominic Vella" wrote in
>>> news:478ec723$0$10472$afc38c87@news.optusnet.com.au:
>>>
>>> CurrentProject.Connection.Execute "ALTER TABLE Table1
>>> ADD COLUMN [Sudent_Acommodation] YesNo DEFAULT Yes"
>>
>> Hi Lyle. I still can't get DEFAULT to work with an existing column,
>> i.e.:
>>
>> strSql = "ALTER TABLE MyTable ALTER COLUMN MyYesNo DEFAULT Yes;"
>> CurrentProject.AccessConnection.Execute strSql
>
> Application name Microsoft Access
> Version 9.0
> Build 6620
>
> I installed this instance just a few weeks ago; I think it's pretty
> standard.
>
> Sub temp()
> CurrentProject.Connection.Execute "ALTER TABLE Table1 ADD COLUMN
> [Student_Acommodation] YesNo DEFAULT Yes" End Sub
>
> Sub temp2()
> CurrentProject.Connection.Execute "ALTER TABLE Table1 ALTER COLUMN
> [Student_Acommodation] YesNo DEFAULT No" End Sub
>
> Both set the Default for the Boolean Field as indicated, as confirmed in
> Design View.
>
> In Datasheet a new record shows as -1 after the first, 0 after the
> second.
>
> Table1 has one other field: ID autonumber.
>
>
> --
> lyle fairfield
>
> In ancient times Ulysses had to outwit the sirens, who had the power to
> charm by their song all sailors who heard them, so that the mariners
> were compelled to cast themselves into the sea to their destruction.
> Today, he would have to deal with (free) Aim-Mail.
>
>
>
>
>