Public Function getRate(ByVal myDate As Date) As Double
Dim Conn As ADODB.Connection
Dim rst As New ADODB.Recordset
Dim strSQL As String
Dim i As Integer
Set Conn = CurrentProject.Connection
strSQL = "Select * FROM 汇率表 ORDER BY 日期 DESC"
rst.Open strSQL, Conn, adOpenKeyset, adLockOptimistic
rst.MoveFirst
For i = 1 To rst.RecordCount
If rst("日期") <= myDate Then
getRate = rst("汇率")
Exit For
Else
rst.MoveNext
End If
Next i
rst.Close
Set rst = Nothing
Set Conn = Nothing
End Function 作者: li_wanli 时间: 2013-10-11 20:40 本帖最后由 li_wanli 于 2013-10-11 20:45 编辑