|
Private Sub Command13_Click()
Dim rs As Recordset
Dim fld As Field
Set rs = CurrentDb.OpenRecordset("select * from 要填表 ")
With Me.记录输入.Form.RecordsetClone
.MoveFirst
Do Until .EOF
rs.FindFirst "代码 = '" & .Fields("代码") & "' and " & "方式 ='" & .Fields("出入方式") & "'"
If rs.NoMatch Then
rs.AddNew
rs![代码] = Me!记录输入!代码
rs![方式] = Me!记录输入!出入方式
Else
rs.Edit
End If
'以日期为列字段来搜索,有,则直接赋值,没有新建字段,再填入值
Dim m As String
m = Format(.Fields("日期"), "yyyy-m-d") 'Trim(CStr(Me!记录输入!日期))
m = Replace(m, "-", "/")
For Each d In rs.Fields
If d.Name = m Then
rs.Fields(d.Name) = .Fields("数量")
rs.Update
End If
Next d
.MoveNext
Loop
End With
rs.Close
Set rs = Nothing
End Sub |
|