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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel - Access

Status
Not open for further replies.

simoncpage

Programmer
Apr 4, 2002
256
GB
Hi, I want to create a new database from Excel and feed in info from the sheet. Can I create a blank database from excel or does it need to be created first, anyone??

Thanks
Simon
 
I have actually done this now, stuck on something else.

Heres the code for creating my blank access db

Sub createdb()

Dim strCon As String
Dim oCat As New ADOX.Catalog

strCon = oCat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source = c:\new.mdb;")

End Sub


Now I am trying to create a table in that db with

Sub CreateAccessTable(StrDBPath As String)

Dim catDB As ADOX.Catalog
Dim tblNEW As ADOX.Table

Set catDB = New ADOX.Catalog
catDB.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & StrDBPath

Set tblNEW = New ADOX.Table
With tblNEW
.Name = "Contacts"

With .Columns
.Append "FirstName", adVarWChar
.Append "Lastname", adVarWChar
.Append "Phone", adVarWChar
.Append "Notes", adLongVarChar
End With
End With

catDB.Tables.Append tblNEW -----this keeps telling me its type is invalid!? WHY?????????????????????????????

Set catDB = Nothing
End Sub

Any help would be most appreciated
Simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top