|
Private Sub Command5_Click()
On Error GoTo Err_Command5_Click
Dim bh As String
Dim strWhere As String '定义条件字符串
Dim strSQL As String
strWhere = "" '设定初始值-空字符串
If Not IsNull(Me.Combo6) Then
'有输入
strWhere = strWhere & "([名称] like '*" & Me.Combo6 & "*') AND "
End If
If Len(strWhere) > 0 Then
'有输入条件
strWhere = Left(strWhere, Len(strWhere) - 5)
End If
bh = Val(Right(Nz(DLookup("报表编号", "表1", "名称='" & Me.Combo6 & "'")), 3)) + 1
bh = Format(Date, "yyyymmdd") & Format(bh, "000")
strSQL = "update 表1 set 报表编号='" & bh & "' where 名称 like '*" & Me.Combo6 & "*'"
CurrentDb.Execute strSQL
Me.表1.Form.Filter = strWhere
Me.表1.Form.FilterOn = True
Exit_Command5_Click:
Exit Sub
Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click
End Sub |
|