|
原帖由 Henry D. Sy 于 2009-1-9 07:55 发表
建议一步到位,直接双击记录,没有必要分成两步完成。
- Function DblRecord()
- Dim strFldVal As String
- Dim strWhere As String
- Dim strSQL As String
- Dim dtmDate As Date
- If Not NewRecord Then
- strFldVal = Me.字段4 & " " & Me.字段2
- dtmDate = DateAdd("m", -2, Me.字段4)
- strWhere = "编号=" & Me.编号
- strSQL = "update 表2 set 字段2='" & strFldVal & "',字段3=#" & dtmDate & _
- "#,字段4=#" & dtmDate & "# where " & strWhere
- CurrentDb.Execute strSQL
- Me.Parent.表2_子窗体.Requery
- End If
- End Function
- Private Sub Form_Load()
- Dim ctl As Control
- For Each ctl In Me.Controls
- If TypeOf ctl Is TextBox Then
- ctl.OnDblClick = "=DblRecord"
- End If
- Next
- End Sub
复制代码
[ 本帖最后由 Henry D. Sy 于 2009-1-9 08:03 编辑 ] |
|