Private Sub Text2_Validate(Cancel As Boolean) Dim gcbh As String
Dim gcmc As String
gcbh = Trim(Text2.Text)
rec.Open "select * from zdgc where gcdm='"& trim(text2.text)&"' ", serverconnect, adOpenKeyset, adLockOptimistic,adcmdtext
If not rec.bof Then
gcmc = rec.Fields("gcmc").Value &""
Else
Text2.Text = ""
End If
rec.Close
if gcbh<>"" then Text3.Text = gcmc
End Sub
试试看,换一个事件
Dim gcmc As String
gcbh = Trim(Text2.Text)
rec.Open "select * from zdgc where gcdm='"& trim(text2.text)&"' ", serverconnect, adOpenKeyset, adLockOptimistic,adcmdtext
If not rec.bof Then
gcmc = rec.Fields("gcmc").Value &""
Else
Text2.Text = ""
End If
rec.Close
if gcbh<>"" then Text3.Text = gcmc
End Sub
试试看,换一个事件
If rec.recordcount Then
Text3.Text= rec.Fields("gcmc").Value
Else if
Text2.Text = ""
End If
rec.Close
"select * from zdgc where gcdm='"& trim(text2.text)&"' "就不行了还是
Private Sub Text2_Validate(Cancel As Boolean)
Dim gcmc As String
Dim gcbh As String
gcbh = Trim(Text2.Text)
gcmc = ""
rec.Open "select * from zdgc ", serverconnect, adOpenKeyset, adLockOptimistic
Do Until rec.EOF
If rec!gcdm = gcbh Then gcmc = rec!gcmc
rec.MoveNext
Loop
rec.Close
Text3.Text = gcmc
End Sub