Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Writting to tables in Access
I need to write and read data in an MSAccess mdb from Excel. I've tried
different variations of the "OpenDatabase" syntax to no avail. Do you have an example of code that will enable me to write and read data from MSAccess tables? Catherine |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Writting to tables in Access
Here is some code for you. You just need to change the location of the
database, the table and the field names. This also requires a reference to the ADO library which is added by doing the following: In the checking in the VBA window Tools - References - Microsoft ADO ... Private Const m_cDBLocation As String = "C:\Forecast.mdb" Private Const m_cLogFile As String = "tblLogFile" Public Sub LogIn() Dim cnt As New ADODB.Connection Dim rst As New ADODB.Recordset ' Open connection to the database cnt.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & m_cDBLocation & ";" rst.Open m_cLogFile, cnt, adOpenKeyset, adLockOptimistic, adCmdTableDirect rst.AddNew rst.Fields("User Name") = "Tada" rst.Fields("In As") = "Shazam" rst.Fields("Logged") = "Whoopee" rst.Fields("Time") = Now() rst.Update ' Close ADO objects rst.Close cnt.Close Set rst = Nothing Set cnt = Nothing End Sub Hope this helps... "Catherine Benoit" wrote: I need to write and read data in an MSAccess mdb from Excel. I've tried different variations of the "OpenDatabase" syntax to no avail. Do you have an example of code that will enable me to write and read data from MSAccess tables? Catherine |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Writting to tables in Access
http://www.erlandsendata.no/english/...php?t=envbadac
-- Regards, Tom Ogilvy "Catherine Benoit" wrote in message ... I need to write and read data in an MSAccess mdb from Excel. I've tried different variations of the "OpenDatabase" syntax to no avail. Do you have an example of code that will enable me to write and read data from MSAccess tables? Catherine |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Comparing tables in access | Excel Discussion (Misc queries) | |||
VLOOKUP from Access Tables | Excel Discussion (Misc queries) | |||
VLOOKUP from Access Tables | Excel Worksheet Functions | |||
Access queries/tables | Excel Discussion (Misc queries) | |||
Access tables in Excel | Excel Discussion (Misc queries) |