Hi experts,
I'm using vba to do my coding. I have to check whether the data exists in the db or not. so I'd done this to check it.
Set rs = New ADODB.Recordset
With rs
.Open "pr_q", cn, adOpenKeyset, adLockOptimistic, adCmdTableDirect
curr_year = Year(Date)
q = 4
.MoveLast
.Find "Q=" & q, , adSearchBackward
End With
* pr_q is the query name & "Q" is the field name
If rs("Q") = " & q & " & rs("Year") = " & curr_year & " Then
Set rs = New ADODB.Recordset
With rs
.Open "select sector, year, sum(val(prcompany))/count(sector) as Mean, sum(val(prcompany))/2 as Median from pr_q where year=" & curr_year & " and Q=" & q - 3 & " group by year, sector order by sector", cn
- sequence of action-
ElseIf rs("Q") = " & q-1 & " & rs("Year") = " & curr_year & " Then
Set rs = New ADODB.Recordset
With rs
.Open "select sector, year, sum(val(prcompany))/count(sector) as Mean, sum(val(prcompany))/2 as Median from pr_q where year=" & curr_year & " and q= 'Q3' group by year, sector order by sector", cn
-sequence of action-
Else
End if
'===================================================
The problem is, it doesn't go into my loop. I'd check my condition few times, but still can't find the solution. Please help me.. :( thank you so much.