Dim b As Integer
Private Sub Command1_Click()
k = InStr(a, Text2, Text1)
If k >0 Then
Command1.Caption = "查找下一个"
a = k + Len(Text1)
Text2.SetFocus
Text2.SelStart = k - 1
Text2.SelLength = Len(Text1)
b = b + 1
Else
MsgBox "查找完毕!共找到 " &b &" 个 " &Text1
Command1.Caption = "查找"
a = 1
End If
'Print k
End Sub
Private Sub Form_Load()
Label1 = "要查找的内容:"
Command1.Caption = "查找"
a = 1
End Sub
Private Sub Command1_Click()'查询代码
Dim ID11,ID12,ID13,ADDR
If Val(Text1.Text)<>0 then
strSQL="Select * from 数据表1 where ID1=" &Val(Text1.Text) &" or ID2=" &Val(Text1.Text) &" or ID3=" &Val(Text1.Text) &""
RS.Open strSQL,conn,2,2
If Not RS.EOF Then
Text1.Text=RS!Name
ID11=RS!ID1
ID12=RS!ID2
ID13=RS!ID3
ADDR=RS!Address
strSQL1="Select * from 数据表2"
RS1.Open strSQL1,conn,3,3
RS1.AddNew
RS1!ID1=ID11
RS1!ID2=ID12
RS1!ID3=ID13
RS1!Name=Text1.text
RS1!Address=ADDR
RS1.Updata
RS1.Close
Else
MsgBox"没有查询到需要查询的记录!"
End If
RS.Close
Else
MsgBox"输入的数据必须是数字!"
End If
End Sub
前提:数据表1和数据表2在同一数据库中,必须已经链接了数据库。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)