Public Function yearstemp(tempperiod As Integer)
Dim a, b, c, d As Date
a = DLookup("[设定日期]", "设定日期")
b = DLookup("[(stop)期款日期]", "成本核算数据")
'c = DLookup("[设定日期]", "设后面把函数里要用到的字段统一改成了从表中引定日期")
d = DLookup("[(start)期款日期]", "成本核算数据")
Debug.Print a, b
If Year(a) > tempperiod Or a > b Or Year(b) < tempperiod Then
yearstemp = 0
ElseIf Year(a) = tempperiod And Year(b) = tempperiod Then
yearstemp = Month(b) - Month(a) + 1
ElseIf Year(a) = tempperiod And a <= d Then
yearstemp = 13 - Month(d)
ElseIf Year(a) = tempperiod And a > d Then
yearstemp = 13 - Month(a)
ElseIf Year(a) < tempperiod And Year(b) = tempperiod Then
yearstemp = Month(b)
Else
yearstemp = 12
End If
Sub oprecordset()
On Error GoTo except
Dim recordset As New ADODB.recordset
recordset.Open "成本核算查询", CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly, adCmdTableDirect
Do Until recordset.EOF
Debug.Print recordset![设定日期], recordset![(start)期款日期]
recordset.MoveNext
Loop
recordset.Clone
Set recordset = Nothing
Exit Sub
except:
MsgBox Err.Description, vbCritical
End Sub 作者: enimo 时间: 2006-2-14 19:19
怎么没人知道吗作者: enimo 时间: 2006-2-15 17:01
谢谢大家的关注,问题已经解决