I created a query in Access and exported it to a file so my co-worker can update and changes. I need now to be able to create an Update Query from Excel to Access to update the data in the query. However I'm not really sure on how to go about doing it. I took the following code and changed to fit my datbase but I don't see an update area in there. Am I on the right track or way off??
Any help would be greatly appreciated.
I have the following code:
I'm not sure about the variable Status. This isn't exactly what I want... but the fields would look up the query with the Column A.
Cross-Post: http://www.mrexcel.com/forum/showthread.php?t=487425
Any help would be greatly appreciated.
I have the following code:
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
I'm not sure about the variable Status. This isn't exactly what I want... but the fields would look up the query with the Column A.
Cross-Post: http://www.mrexcel.com/forum/showthread.php?t=487425
Last edited by a moderator: