|
本帖最后由 todaynew 于 2010-5-2 09:28 编辑
Public Function IntRec(Tbname As String, Fldname As String, LYear As Long, LMonth As Long)
'功能:向表中插入当月按天数计算的记录数
'参数:Tbname---插入记录的表,Fldname---表中表示日期的字段,LYear---年, LMonth---月
'示例:IntRec("日记表","日期",me.年.value,me.月.value)
Dim MYdate1 As Date, MYdate2 As Date
Dim num As Long
Dim rs As New ADODB.Recordset
Dim i As Long
MYdate1 = DateSerial(LYear, LMonth, 1)
MYdate2 = DateSerial(LYear, LMonth + 1, 1)
num = DateDiff("d", MYdate1, MYdate2)
rs.Open Tbname, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
rs.AddNew
rs("日期").Value = MYdate1
rs.Update
For i = 1 To num - 1
rs.AddNew
rs("日期").Value = DateAdd("d", 1, MYdate1 + i - 1)
rs.Update
Next
rs.Close
End Function |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|