Hi Prav,
with all due respect, it is quicker to (1) go to design view of the
table, (2) manually enter DefaultValue--> True (type first one, copy, go
to next Yes/No field, paste in DefaultValue property, etc) ... than it
is to write a program to do it (but I did it for you anyway

...
making certain assumptions )
Because I did not specify fieldnames in the program, it loops through
ALL Yes/No fields... if this is not what you want, you will have to
manually change them after the routine runs)
modify the parameters sent to setYnDefaultValue in RunsetYnDefaultValue
for your values (first tablename in quotes and the what you want to set
DefaultValues to, true or false)
Make sure you have a reference to a Microsoft DAO Library
from the menu in a module window --> Tools, References...
(check Microsoft DAO 3.6 Object Library or something similar)
Then, compile the db*
After everything compiles okay, then create a new general module
put this code in a general module
'~~~~~~~~~~~~~~~~
Sub RunsetYnDefaultValue()
setYnDefaultValue "YourTablename", True
End Sub
'~~~~~~~~~~~~~~~~
Sub setYnDefaultValue( _
pTablename As String, _
pBoo As Boolean)
'written by Crystal
'strive4peace2006 at yahoo dot co,
'8-16-06
'NEEDS REFERENCE TO
'Microsoft DAO Library
On Error GoTo Proc_Err
Dim db As DAO.Database, tdf As DAO.TableDef
Dim fld As DAO.Field, i As Integer
Set db = CurrentDb
Set tdf = db.TableDefs(pTablename)
i = 0
With tdf
For Each fld In tdf.Fields
If fld.Type = dbBoolean Then
fld.DefaultValue = pBoo
i = i + 1
End If
Next fld
End With
db.TableDefs.Refresh
MsgBox "Done setting " & i _
& " Yes/No fields in " _
& pTablename _
& " to DefaultValue = " & pBoo, , "Done"
Proc_Exit:
On Error Resume Next
Set fld = Nothing
Set tdf = Nothing
Set db = Nothing
Exit Sub
Proc_Err:
MsgBox Err.Description, , "ERROR " & Err.Number & " setYnDefaultValue"
'press F8 to step through code and debug
'remove next line after debugged
Stop: Resume
Resume Proc_Exit
End Sub
'~~~~~~~~~ Compile ~~~~~~~~~
Whenever you change code or references, your should always compile
before executing.
from the menu in a module window: Debug, Compile
fix any errors on the yellow highlighted lines
keep compiling until nothing happens (this is good!)
'~~~~~~~~~~~~
then, after you paste in this code, compile your database again...
when everything is okay, click your mouse in RunsetYnDefaultValue and
press F5 to Run!
Voila! Check the specified table and all DefaultValue properties of
YesNo fields should be whatever you specified (True in the example).
'~~~~~~~~~~~~~~~~~~`
One thing I want to mention ... use of Yes/No fields -- especially that
many ... implies that your data structures perhaps have opportunities
for improvement...
Warm Regards,
Crystal
*

have an awesome day

*
MVP Access
strive4peace2006 at yahoo.com
*