|
本帖最后由 djt 于 2009-8-22 23:00 编辑
replace函数97不能用,你再改过来
Private Sub Command13_Click()
Dim rs As Recordset
Dim fld As Field
Dim d As Field
Set rs = CurrentDb.OpenRecordset("select * from 要填表 ")
With Me.记录输入.Form.RecordsetClone
.MoveFirst
Do Until .EOF
rs.FindFirst "代码 = '" & Me!记录输入!代码 & "' and " & "方式 ='" & Me!记录输入!出入方式 & "'"
If rs.EOF() Then 这里有问题,需要改正 用 RS.NOMATCH
rs.AddNew
rs![代码] = Me!记录输入!代码
rs![方式] = Me!记录输入!出入方式
Else
rs.Edit
End If
'以日期为列字段来搜索,有,则直接赋值,没有新建字段,再填入值
Dim m As String
Dim dt As Date
dt = Me!记录输入!日期
m = Year(dt) & "/" & Month(dt) & "/" & Day(dt)
' m = Replace(m, "-", "/")
For Each d In rs.Fields
If d.Name = m Then
rs.Fields(d.Name) = Me.记录输入!数量
rs.Update
End If
Next d
.MoveNext
Loop
End With
rs.Close
Set rs = Nothing
End Sub |
|