以下是引用片段:
实现功能的关键代码为: Private Sub Form_Activate() If Me.Tag = "tmp" Then Me.Tag = "" Exit Sub End If If Me.txtID.Enabled = True Then '新住房 Me.txtsshz.Text = "" Me.txtssjmq.Text = "" Me.txtsssq.Text = "" Me.txtbz.Text = "" Me.txtjzmj.Text = "" Me.txtcsjg.Text = "" Me.txtczjg.Text = "" Me.Combocx.ListIndex = 0 Me.Combohx.ListIndex = 0 Me.Combofcxz.ListIndex = 0 Me.DTPickerjcsj.Value = Format(Date, "yyyy-mm-dd") Else '已经存在的住房 根据传递的标志 查询并显示内容 Dim tmprs As New ADODB.Recordset Set tmprs = ExecSql("select * from zfxx, hzxx, jmqxx, sqxx where zfxx.sssq=sqxx.sqdm and zfxx.ssjmq=jmqxx.jmqdm and zfxx.sshz= hzxx.hzdm and zfdm='" & Me.txtID.Text & "'") With tmprs If .RecordCount > 0 Then Me.txtsshz.Text = .Fields("hzxm").Value Me.txtsshz.Tag = .Fields("sshz").Value Me.txtssjmq.Text = .Fields("jmqmc").Value Me.txtssjmq.Tag = .Fields("ssjmq").Value Me.txtsssq.Text = .Fields("sqmc").Value Me.txtsssq.Tag = .Fields("sssq").Value Me.txtjzmj.Text = .Fields("zfjzmj").Value Me.Chkifcs.Value = .Fields("ifxs").Value Me.txtcsjg.Text = .Fields("xsjg").Value Me.Chkcz.Value = .Fields("czbz").Value Me.txtczjg.Text = .Fields("czjg").Value Me.txtbz.Text = .Fields("bz").Value Me.DTPickerjcsj.Value = .Fields("jcsj").Value Me.Combocx.ListIndex = GetComboIndex(Me.Combocx, Trim(.Fields("cx").Value)) Me.Combohx.ListIndex = GetComboIndex(Me.Combohx, Trim(.Fields("hx").Value)) Me.Combofcxz.ListIndex = GetComboIndex(Me.Combofcxz, Trim(.Fields("fcxz").Value)) End If End With
End If End Sub
Private Sub MMButton_XPBE2_Click() Dim strresult As String
If Me.txtID.Enabled = True Then '添加住房信息 If Me.txtID.Text = "" Or Me.txtssjmq.Text = "" Or Me.txtsssq.Text = "" Then MsgBox "住房代码或所属社区或所属居民区不能为空" Exit Sub End If If ExecSql("select * from zfxx where zfdm='" & Trim(Me.txtID.Text) & "'").RecordCount > 0 Then MsgBox "住房代码重复,不能保存!" Exit Sub End If strresult = Exec_SqL("insert into zfxx(zfdm, sshz, ssjmq, sssq, zfjzmj, jcsj, ifxs, xsjg, czbz, czjg, cx, hx, fcxz, bz) " _ & " values('" & Trim(Me.txtID.Text) & "','" & Trim(Me.txtsshz.Tag) & "','" & Trim(Me.txtssjmq.Tag) & "','" & Trim(Me.txtsssq.Tag) & "'," _ & Val(Me.txtjzmj.Text) & ",'" & Me.DTPickerjcsj.Value & "'," & Me.Chkifcs.Value & "," & Val(Me.txtcsjg.Text) & "," & Me.Chkcz.Value & "," & Val(Me.txtczjg.Text) & ",'" _ & Trim(Me.Combocx.Text) & "','" & Trim(Me.Combohx.Text) & "','" & Trim(Me.Combofcxz.Text) & "','" & Me.txtbz.Text & "')") If strresult <> "OK" Then MsgBox strresult Exit Sub End If Call frmZFWH.UpdateList Else '修改住房信息 If Me.txtssjmq.Text = "" Then MsgBox "所属社区或所属居民区不能为空" Exit Sub End If strresult = Exec_SqL("update zfxx set sshz='" & Trim(Me.txtsshz.Tag) & "'," _ & " ssjmq ='" & Trim(Me.txtssjmq.Tag) & "', " _ & " sssq ='" & Trim(Me.txtsssq.Tag) & "', " _ & " zfjzmj =" & Trim(Me.txtjzmj.Text) & ", " _ & " jcsj ='" & Me.DTPickerjcsj.Value & "', " _ & " ifxs =" & Me.Chkifcs.Value & ", " _ & " xsjg =" & Val(Me.txtcsjg.Text) & ", " _ & " czbz =" & Me.Chkcz.Value & ", " _ & " czjg =" & Val(Me.txtczjg.Text) & ", " _ & " cx ='" & Trim(Me.Combocx.Text) & "', " _ & " hx ='" & Trim(Me.Combohx.Text) & "', " _ & " fcxz ='" & Trim(Me.Combofcxz.Text) & "', " _ & " bz ='" & Me.txtbz.Text & "' where " _ & " zfdm ='" & Trim(Me.txtID.Text) & "'") If strresult <> "OK" Then MsgBox strresult Exit Sub End If Call frmZFWH.UpdateList End If log = InsertOperateLog("编辑住房信息", "成功") Unload Me End Sub
|