|
窗体在表二,通过删除记录按钮为什么删不了表一的数据,但是如果学员查询停在表一就可以把数据删掉,这段代码哪里的问题,求老师指正,谢谢
Private Sub CommandButton8_Click() '删除记录
Dim xrow As Long 这个指定删除表一的代码似乎没有用
With Sheet1
If Len(店名) = 0 Then
MsgBox "内容为空,删除学员信息失败!!!", 16, "温馨提示……": Exit Sub
End If
If MsgBox("是否真的要删除该学员信息?", vbQuestion + vbYesNo, "删除学员") = vbYes Then
Dim j
Application.ScreenUpdating = False
xrow = Range("A2").CurrentRegion.Rows.Count + 1
For j = Cells(Rows.Count, 2).End(3).Row To 3 Step -1
If Cells(j, 1) = 学员电话.Text Then
If Val(姓名.Text) = Val(Cells(j, 2)) And (性别.Text) = (Cells(j, 3)) And (区域.Text) = (Cells(j, 4)) And Val(店名.Text) = Val(Cells(j, 5)) And (卡项名称.Text) = (Cells(j, 6)) And Val(卡号.Text) = Val(Cells(j, 7)) And Val(老板电话.Text) = Val(Cells(j, 8)) And Val(激活日期.Text) = Val(Cells(j, 9)) And Val(到期日期.Text) = Val(Cells(j, 10)) Then
Rows(j).Delete
End If
End If
Next j
Application.ScreenUpdating = True
学员电话.Value = ""
姓名.Value = ""
性别.Value = ""
区域.Value = ""
店名.Value = ""
卡项名称.Value = ""
卡号.Value = ""
老板电话.Value = ""
激活日期.Value = ""
到期日期.Value = ""
UserForm7.学员电话.Enabled = True
UserForm7.姓名.Enabled = True
UserForm7.性别.Enabled = True
UserForm7.区域.Enabled = True
UserForm7.店名.Enabled = True
UserForm7.卡项名称.Enabled = True
UserForm7.卡号.Enabled = True
UserForm7.老板电话.Enabled = True
UserForm7.激活日期.Enabled = True
UserForm7.到期日期.Enabled = True
MsgBox "删除学员成功!!!", 48, "温馨提示……"
End If
'学员电话.Text = ""
'姓名.Text = ""
'性别.Text = ""
'区域.Text = ""
'店名.Text = ""
'卡项名称.Text = ""
'卡号.Text = ""
'老板电话.Text = ""
'激活日期.Text = ""
'到期日期.Text = ""
End With
End Sub
|
|