Private Sub Cmd_Fing_Click()
Dim str As String
str = InputBox$("输入你要查询的货品编号:", "系统提示")
If str = "" Then Exit Sub
Adodc2.RecordSource = "select * from tb_IN where 货品编号='" + str + "'"
Adodc2.Refresh
If Adodc2.Recordset.RecordCount > 0 Then
Text1(1).Text = Adodc2.Recordset.Fields(1)
Text1(2).Text = Adodc2.Recordset.Fields(2)
Text1(3).Text = Adodc2.Recordset.Fields(7)
Text1(4).Text = Adodc2.Recordset.Fields(8)
Text1(5).Text = Adodc2.Recordset.Fields(14)
Else
MsgBox "没有你需要的信息!", , "系统提示"
End If
End Sub
用查询就出现至少一个参数那个能帮下非常感谢!
Dim str As String
str = InputBox$("输入你要查询的货品编号:", "系统提示")
If str = "" Then Exit Sub
Adodc2.RecordSource = "select * from tb_IN where 货品编号='" + str + "'"
Adodc2.Refresh
If Adodc2.Recordset.RecordCount > 0 Then
Text1(1).Text = Adodc2.Recordset.Fields(1)
Text1(2).Text = Adodc2.Recordset.Fields(2)
Text1(3).Text = Adodc2.Recordset.Fields(7)
Text1(4).Text = Adodc2.Recordset.Fields(8)
Text1(5).Text = Adodc2.Recordset.Fields(14)
Else
MsgBox "没有你需要的信息!", , "系统提示"
End If
End Sub
用查询就出现至少一个参数那个能帮下非常感谢!
2,语句中的表名与字段名是否存在
改成
Adodc2.RecordSource = "select * from tb_IN where 货品编号= ' " & str & " ' "
Adodc2.RecordSource = "select * from tb_IN where 货品编号 = '" & replace(str,"'","''") & "'"
Adodc2.Refresh If Adodc2.Recordset.RecordCount > 0 Then
Text1(1).Text = Adodc2.Recordset.Fields(1)
Text1(2).Text = Adodc2.Recordset.Fields(2)
Text1(3).Text = Adodc2.Recordset.Fields(7)
Text1(4).Text = Adodc2.Recordset.Fields(8)
Text1(5).Text = Adodc2.Recordset.Fields(14)
Else
MsgBox "没有你需要的信息! ", , "系统提示 "
End If
大哥,str是VB保留字,不知道吗?换一个,如str1
Adodc2.Refresh If Adodc2.Recordset.RecordCount > 0 Then
Text1(1).Text = Adodc2.Recordset.Fields(1)
Text1(2).Text = Adodc2.Recordset.Fields(2)
Text1(3).Text = Adodc2.Recordset.Fields(7)
Text1(4).Text = Adodc2.Recordset.Fields(8)
Text1(5).Text = Adodc2.Recordset.Fields(14)
Else
MsgBox "没有你需要的信息! ", , "系统提示 "
End If