搜索数据并显示在MSFLEXGRID控件中,为什么有些记录搜索不到,高手帮解决下
If Text1.Text = "" And Text2.Text = "" And Text3.Text = "" ThenMsgBox "请输入查询条件!"
Exit Sub
End If
If Text1.Text <> "" And Text2.Text = "" And Text3.Text = "" Then
str = "select * from 会员表 where 姓名='" & Trim(Text1.Text) & "'"
End If
If Text2.Text <> "" And Text1.Text = "" And Text3.Text = "" Then
str = "select * from 会员表 where 会员卡号='" & Trim(Text2.Text) & "'"
End If
If Text3.Text <> "" And Text2.Text = "" And Text1.Text = "" Then
str = "select * from 会员表 where 备注='" & Trim(Text3.Text) & "'"
End If
re.Open str, conn, 1, 3
If re.RecordCount = 0 Then
MsgBox "你要搜索的客户不存在,请核对!"
Exit Sub
End If
Me.MSFlex1.Rows = re.RecordCount + 1
For i = 1 To re.RecordCount
For j = 0 To 4
Me.MSFlex1.Row = i
Me.MSFlex1.Col = j
If re(j) = "" Then
Me.MSFlex1.Text = ""
Else
Me.MSFlex1.Text = re(j)
End If
Next j
re.MoveNext
Next i
re.Close