Sorry, looks like I need to take this one step further. I'm looking to add an additional WHERE statement. So the data that gets returned should be Current Year AND have the department name = 3D. I know I'm close, but I can't seem to figure out the apostrophe or quote mark alignments. I bolded the line below that's giving me issues.
Dim conn As ADODB.Connection
Dim stFund, stYear As String
Dim rs As ADODB.Recordset
Dim stSQL As String
Set conn = New ADODB.Connection
conn.Open xConn
Set rs = New ADODB.Recordset
stSQL = "SELECT [ADJ_Table].[ID]"
stSQL = stSQL + " , [AdjProcessError].[ProcessErrorID]"
stSQL = stSQL + " , [AdjustmentDate]"
stSQL = stSQL + " , [WorkType]"
stSQL = stSQL + " , [ReasonCode]"
stSQL = stSQL + " , [FundNo]"
stSQL = stSQL + " , [ShareholderAccountNumber]"
stSQL = stSQL + " , [DescriptionofProblem]"
stSQL = stSQL + " FROM [AdjProcessError] INNER JOIN [ADJ_Table] ON [AdjProcessError].RequestNbr = [ADJ_Table].ID"
stSQL = stSQL & " WHERE (Year ([AdjustmentDate]) =" & Year(Now()) And ([AdjProcessError].[ProcessErrorDepartment]) =" & "'3D'"
stSQL = stSQL + " ORDER BY [ADJ_Table].[ID] DESC"
Set rs = conn.Execute(stSQL)
Sheets("External Errors Detail").Select
Range("A2:H700000").ClearContents
Range("A2").CopyFromRecordset rs
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing