AccessGuruCarl
Programmer
Create a new Access Database using VB.
I have 2 procedures. One creates a new Access .mdb file.
The next sub creates the tables.
My question is how do I set/format booleen valued properties to a checkbox. During execution it creates a Textbox!
Next issue is formatting a valuelist, and populating the table with the values, instead of populating a combo at run-time.
Here is a sample of create tables code...
Thanks in advance....
AccessGuruCarl
Programmers helping programmers
you can't find a better site.
I have 2 procedures. One creates a new Access .mdb file.
The next sub creates the tables.
My question is how do I set/format booleen valued properties to a checkbox. During execution it creates a Textbox!
Next issue is formatting a valuelist, and populating the table with the values, instead of populating a combo at run-time.
Here is a sample of create tables code...
Code:
Dim catDB As ADOX.Catalog
Dim tblNew As ADOX.Table
Dim col As ADOX.Column
Set catDB = New ADOX.Catalog
' Open the catalog
catDB.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & sDatabaseToCreate
' Create the tables
'===============================================
' Create tblRaceInfo Table
Set tblNew = New ADOX.Table
tblNew.Name = "tblRaceInfo"
Set col = New ADOX.Column
' First Create an Autonumber column
With col
.ParentCatalog = catDB
.Type = adInteger
.Name = "RaceID"
.Properties("Autoincrement") = True
.Properties("Description") = "Unique Identifer - " & _
"Do Not Alter"
End With
tblNew.Columns.Append col
' Now add the rest of the columns
With tblNew
' Create fields and append them to the Columns collection.
With .Columns
.Append "TitleLine1", adVarWChar
.Append "TitleLine2", adVarWChar
.Append "TitleLine3", adVarWChar
.Append "RaceType", adVarWChar 'VALUELIST
.Append "LaneCnt", adVarWChar
End With
' Set column specfic attributes.
With .Columns("TitleLine1")
.DefinedSize = 50
.Attributes = adColNullable
End With
With .Columns("TitleLine2")
.DefinedSize = 50
End With
With .Columns("TitleLine3")
.DefinedSize = 50
End With
[!] With .Columns("RaceType")
.DefinedSize = 25
**** Needs to be a ValueList - Car,Truck,Boat
End With[/!]
With .Columns("LaneCnt")
.DefinedSize = 2
End With
End With
' Add the new Table to the Tables collection of the database.
catDB.Tables.Append tblNew
Set col = Nothing
Set tblNew = Nothing
'===============================================
'
'===============================================
' Create tblRacers Table
Set tblNew = New ADOX.Table
tblNew.Name = "tblRacers"
Set col = New ADOX.Column
' First Create an Autonumber column
With col
.ParentCatalog = catDB
.Type = adInteger ' adText does not exist
.Name = "RacerID"
.Properties("Autoincrement") = True
.Properties("Description") = "Unique Identifer - " & _
"Do Not Alter"
End With
tblNew.Columns.Append col
' Now add the rest of the columns
With tblNew
' Create fields and append them to the
' Columns collection of the new Table object.
With .Columns
.Append "DenNumber", adInteger
.Append "FirstName", adVarWChar
.Append "LastName", adVarWChar
.Append "CarNumber", adInteger
.Append "VehicleWeight", adInteger
.Append "ClassID", adInteger
.Append "RankID", adInteger
.Append "PassedInspection", adBoolean 'CHECKBOX
End With
' Set column specfic attributes.
With .Columns("DenNumber")
.Attributes = adColNullable
End With
With .Columns("FirstName")
.DefinedSize = 50
End With
With .Columns("LastName")
.DefinedSize = 50
.Attributes = adColNullable
End With
[!] With .Columns("PassedInspection")
' access uses DisplayConrol... Didn't work
' .displaycontrol = 106
**** NEEDS TO BE A CHECKBOX[/!]
End With
End With
' Add the new Table to the Tables collection of the database.
catDB.Tables.Append tblNew
Set col = Nothing
Set tblNew = Nothing
AccessGuruCarl
Programmers helping programmers
you can't find a better site.