删除后,mshflexgrid不能同步显示
Private Sub Command2_Click() '删除记录
Dim ans As String
Dim sqlstr As String
Dim param As ADODB.Parameter
Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
Set param = New ADODB.Parameter
ans = Msgbox("确定要删除此记录吗?", vbYesNo, "提示")
If ans = vbYes Then
sqlstr = "delete from book where [总号]= '" & Trim(Text1.Text) & "'"
With param
.Direction = adParamInput
.Type = adBSTR
.Size = 8
.Value = Text1.Text
End With
cmd.Parameters.Append param
cmd.CommandText = sqlstr
cmd.CommandType = adCmdText
Set cmd.ActiveConnection = con
Set rst1 = cmd.Execute
'/文本框清空
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""
Text11.Text = ""
Text12.Text = ""
Text13.Text = ""
frmMsg.Show
frmMsg.info.Visible = True
frmMsg.Text1.Text = "删除成功!"
set mshflexgrid1=nothing
set mshflexgrid1=rst
else
exit sub
end if
End Sub
[解决办法]
问题没有表述清楚,删除之后重新载入或直接从表格控件中移除
[解决办法]
重新绑定一次数据源呢!