Very new to any form of code. Attempting to run a script in VBA that will pull data from an access database using SQL and put it into an excel spreadsheet. Code is similar to below. Runs clean but I don't know how to use the data it is pulling. Thanks in advance.
Sub Get_Data()
Dim cn As Object
Dim rs As Object
Dim strFile As String
Dim strCon As String
Dim strSQL, strInput As String
strFile = "S:\Location.Database.accdb"
strCon = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & strFile
Set cn = CreateObject("ADODB.Connection")
cn.Open strCon
strInput = InputBox("Input Desired Name")
strSQL = "SELECT NAME, Location WHERE NAME =""'strInput'"";"
cn.Execute strSQL
cn.Close
Set cn = Nothing
End Sub
Recordset
object to hold the results of the query. Note that you have declaredrs
but aren't using it anywhere in your code.