关于为什么字段会被清空请教高手
两个窗体:conr和require,conr输入查询条件,require显示查询结果。以下是conr的代码。(require没有代码,放置了一个adodc1和一个datagrid1。)Option Explicit
Private Sub Command1_Click()
If Combo1.Text = "请输入字段" Or Text1.Text = "" Then
MsgBox "请输入字段名和字段值", 21, "错误"
Exit Sub
End If
If Combo1.Text = "date" Then
require.Adodc1.RecordSource = "select * from ma where [Date]='" & Text1.Text & "'"
Else
require.Adodc1.RecordSource = "select * from ma where " & Combo1.Text & "='" & Text1.Text & "'"
End If
require.Adodc1.Refresh
If require.Adodc1.Recordset.BOF And require.Adodc1.Recordset.EOF = True Then
MsgBox "没有此项记录!"
Else
Debug.Print "number="; require.Adodc1.Recordset.Fields("number")
require.Show
Debug.Print "number="; require.Adodc1.Recordset.Fields("number")
End If
Combo1.Text = "请选择字段"
Text1.Text = ""
End Sub
Private Sub Form_Load()
Combo1.AddItem "number"
Combo1.AddItem "name"
Combo1.AddItem "date"
Combo1.AddItem "provider"
Combo1.AddItem "stockplace"
Combo1.AddItem "note"
require. = adCmdText
require.Adodc1.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=fudan;Data Source=VM"
End Sub
第一个debug.print显示number=pmc0001,第二个debug.print显示number=null。
中间只隔一个require.show。它是怎样把number清空的呢?请教!
[ 本帖最后由 冰雪清风 于 2009-12-1 16:54 编辑 ]