Bellow is what I have so far. I am calling in query Analog Inputs, but need to specifically call Analog Input from Sheet 'TOC' cell A27 which will be PLCPanel.
VBA Code:
Option Explicit
Sub AnalogInput_DB()
'Path
Dim strPath As String
'Provider
Dim strProv As String
'Connection String
Dim strCn As String
'Connection
Dim Cn As New Connection
'RecordSet for AI
Dim rsQry_AI As New Recordset
'SQL Query for AI
Dim strQry_AI As String
'Establish connection to Project DB. Looks at the filepath specified in cell B1 of Project_DB Sheet
strPath = ActiveWorkbook.Sheets("PAGE").Range("B1").Text
strProv = "Microsoft.ACE.OLEDB.12.0;"
strCn = "Provider=" & strProv & "Data Source=" & _
strPath
'Connection Open
Cn.Open strCn
'SQL Query to import Digital Input Tags
strQry_AI = "SELECT Instruments.PLCPanel, Instruments.Address FROM Instruments WHERE (((Instruments.AnalogInput)=True)) ORDER BY Instruments.PLCPanel;"
rsQry_AI.Open strQry_AI, Cn
'Puts Data into the Device Column of the Digital Device Sheet
ActiveWorkbook.Sheets("AnalogInput").Range("A17").CopyFromRecordset rsQry_AI
Cn.Close
End Sub