Private Sub Form_Current() '作用:单击本子窗体控件后使记录引用到窗体文本框中,达到可编辑的目的。
On Error Resume Next
If Me.Parent.Form!fm_operate2 = 2 Then '在查询的状态下(fm_operate2 = 2),操作有效
Me.Parent.Form.材料ID.Value = [材料ID]
Me.Parent.Form.钢材代码.Value = [钢材代码]
Me.Parent.Form.钢材名称.Value = [钢材名称]
Me.Parent.Form.钢材种类.Value = [钢材种类]
Me.Parent.Form.单位.Value = [单位]
Me.Parent.Form.规格.Value = [规格]
Me.Parent.Form.备注.Value = [备注]
Me.Parent.Form.cmdel.Enabled = True
Me.Parent.Form.cmedit.Enabled = True
End If
End Sub
原“查询”按扭代码:Private Sub cmask_Click() '查询记录
strWhere = ""
On Error GoTo Err_cmask_Click
If (IsNull(Me.钢材代码) = False And Trim(Me.钢材代码) <> "") Then strWhere = strWhere & "([钢材代码] like '*" & Me.钢材代码 & "*') AND "
If (IsNull(Me.钢材名称) = False And Trim(Me.钢材名称) <> "") Then strWhere = strWhere & "([钢材名称] like '*" & Me.钢材名称 & "*') AND "
If (IsNull(Me.钢材种类) = False And Trim(Me.钢材种类) <> "") Then strWhere = strWhere & "([钢材种类] like '*" & Me.钢材种类 & "*') AND "
If (IsNull(Me.规格) = False And Trim(Me.规格) <> "") Then strWhere = strWhere & "([规格] like '*" & Me.规格 & "*') AND "
If (IsNull(Me.备注) = False And Trim(Me.备注) <> "") Then strWhere = strWhere & "([备注] like '*" & Me.备注 & "*') AND "
If (IsNull(Me.单位) = False And Trim(Me.单位) <> "") Then strWhere = strWhere & "([单位] like '*" & Me.单位 & "*') AND "
If Len(strWhere) > 0 Then strWhere = Left(strWhere, Len(strWhere) - 5)
Debug.Print strWhere