In my database I need to export a query to excel so my coworker can update it. Now I need to create a button that will create an Update Query to update any changed information back into the Access query. How can I go about doing this. I have the following from other sources but somethings not right. Am I close to what I need or am I way off?
Any help will be greatly appreciated!
Any help will be greatly appreciated!
Code:
Dim cn As Object, rs As Object, Status As Range
Dim MySql As String, dbfullname As String, myCnt As Long
dbfullname = "P:\Databases\Access Database Development\6.TestDatabases\testtable.mdb"
Set Status = Sheets("testquery").Range("A2") 'SQL Variable
MySql = "SELECT ProjectID,ProjectInfo.OppId,Po_Value,ProjectInfo.Submitter,Comments, " _
& "OppTable.OppId,Customer,Plant,OppTable_Submitter " _
& "FROM testquery WHERE " & _
"projectid ='" & Status & "';" 'Stack your SQL string
Status = Empty 'Clear SQL variable string
Set cn = CreateObject("ADODB.Connection")
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source= " _
& dbfullname & ";" 'Create DB connection
Set rs = CreateObject("ADODB.Recordset")
With rs
Set .ActiveConnection = cn
.Source = MySql 'Pass your SQL
.Open , , 3, 3
myCnt = .RecordCount
.Close
End With
cn.Close
Set rs = Nothing: Set cn = Nothing
End Sub