beetlebailey
Programmer
I am trying to retrieve information from an Access database using the following SQL statement from within Excel VBA. This works fine:
Set conn = New ADODB.Connection
conn.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & "c:\temp\scelestus.mdb" & ";" & _
"Persist Security Info=False"
conn.Open
SQLc = "Select [scheduled qty] from [tbl TTR Data] where [time slot]=1 and [TTRN]=1"
Set rs = conn.Execute(SQLc, , adCmdText)
H1 = rs.Fields("scheduled qty").Value: .Range("H3").Value = H1
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
This does not, I need to sum the various values from the scheduled qty column first, any ideas:
Set conn = New ADODB.Connection
conn.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & "c:\temp\scelestus.mdb" & ";" & _
"Persist Security Info=False"
conn.Open
SQLc = "Select Sum[scheduled qty] as 'sq' from [tbl TTR Data] where [time slot]=1 and [TTRN]=1"
Set rs = conn.Execute(SQLc, , adCmdText)
H1 = rs.Fields("sq").Value: .Range("H3").Value = H1
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
Thank you very much
Set conn = New ADODB.Connection
conn.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & "c:\temp\scelestus.mdb" & ";" & _
"Persist Security Info=False"
conn.Open
SQLc = "Select [scheduled qty] from [tbl TTR Data] where [time slot]=1 and [TTRN]=1"
Set rs = conn.Execute(SQLc, , adCmdText)
H1 = rs.Fields("scheduled qty").Value: .Range("H3").Value = H1
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
This does not, I need to sum the various values from the scheduled qty column first, any ideas:
Set conn = New ADODB.Connection
conn.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & "c:\temp\scelestus.mdb" & ";" & _
"Persist Security Info=False"
conn.Open
SQLc = "Select Sum[scheduled qty] as 'sq' from [tbl TTR Data] where [time slot]=1 and [TTRN]=1"
Set rs = conn.Execute(SQLc, , adCmdText)
H1 = rs.Fields("sq").Value: .Range("H3").Value = H1
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
Thank you very much