I have this tool where employee information needs to be updated. I call in the MDB data to excel in one sheet. Now I use vlookup to see what is there and change it if needed.
I have tried some tricks however some thing seems to be wrong.. please help.
In the above code the file EIM has a table called EIM with NBKID and Person# fields.
I have tried some tricks however some thing seems to be wrong.. please help.
Code:
Sub update() Dim cn As Object Dim rs As Object Dim a As String strFile = "D:\temp excel\EIM.mdb" strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strFile & ";" Set cn = CreateObject("ADODB.Connection") Set rs = CreateObject("ADODB.Recordset") cn.Open strCon a = Sheet2.Range("D4") strSQL = "SELECT * FROM EIM WHERE EIM.NBKID=" & a rs.Open strSQL, cn strSQL = "UPDATE EIM SET EIM.Person#=('" & Sheet2.Range("D5") & "')WHERE EIM.NBKID=('" & Sheet2.Range("D4") cn.Execute strSQL End Sub
In the above code the file EIM has a table called EIM with NBKID and Person# fields.
Comment