Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

changing the format Properties of a field in vba

Status
Not open for further replies.

grmman

MIS
Sep 9, 2003
81
US
I have to create an new/add a field to a table in vba.
I need to set one field to be an boolaen type.
I get that to work but I also have to be able to set the format of the feild to be "yes/no".

I am able to set the defaultvalue prop but I can not get to the format prop.

THANK YOU
here is the code i am using to create the table.
Code:
Sub CreateTable()

   Dim db As DAO.Database
   Dim tbl As DAO.TableDef
   
   ' Open the database
   Set db = DBEngine.OpenDatabase("test1.mdb")

       Set tbl = db.TableDefs("contacts")

   With tbl
       .Fields.Append .CreateField("test", dbBoolean)
       .Fields(1).DefaultValue = "no"           
        
   End With
    
   ' Add the new table to the database.
   'db.TableDefs.Append tbl
  
   db.Close

End Sub
 
Try
[blue][tt]
.Fields(1).Properties("DefaultValue") = 0
[/tt][/blue]
 
ok
How do I set the format propertery of the field.
 
Same way
[blue][tt]
.Fields(1).Properties("Format") = "Yes/No"
[/tt][/blue]
 
I did that and I get an error property not found on that line.

 
I was able to looop thru the prop of the new table and I did not see the format prop come up.
here is that code.
Thanks for any help.

Code:
 Dim objP As DAO.Property
        Dim strS As String

For Each objP In DBEngine(0)(0).TableDefs!contacts.Fields!test.Properties
    strS = objP.Name & ":  "
   On Error Resume Next
   strS = strS & objP.Value
   On Error GoTo 0
   MsgBox strS
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top