刚学VB,这个地方实在整不明白了,帮忙看看我这代码该怎么写啊,谢谢了,打叉的地方是我不会的,什么地方不对,帮忙指正,谢谢。
Private Sub Command5_Click()
If Text2.Text = "" Then
MsgBox ("请在甲方处输入您想要查询的合同,例如:建三江")
Else
Dim sc As String
sc = MsgBox("确实要查询此测区的合同么?", vbOKCancel, "系统提示")
If sc = 1 Then
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim str1 As String
Dim str2 As String
Dim str3 As String
str1 = "provider = microsoft.jet.oledb.4.0;"
str2 = "data source = c:\合同管理\contract.mdb;"
str3 = "jet oledb:database password = "
conn.Open str1 & str2 & str3
strsql = "select * from xiangmu where 甲方 = " & Val(Text2.Text) & ""
rs.Open strsql, conn, 3, 3
If rs!甲方 = Val(Text2.Text) Then
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXX
Else
MsgBox ("不存在此记录")
Text2.Text = ""
XXXXXXXXXXX
XXXXXXXXXXXXXXXXXX
Exit Sub
End If
End If
End If
End Sub
Private Sub Command5_Click()
If Text2.Text = "" Then
MsgBox ("请在甲方处输入您想要查询的合同,例如:建三江")
Else
Dim sc As String
sc = MsgBox("确实要查询此测区的合同么?", vbOKCancel, "系统提示")
If sc = 1 Then
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim str1 As String
Dim str2 As String
Dim str3 As String
str1 = "provider = microsoft.jet.oledb.4.0;"
str2 = "data source = c:\合同管理\contract.mdb;"
str3 = "jet oledb:database password = "
conn.Open str1 & str2 & str3
strsql = "select * from xiangmu where 甲方 = " & Val(Text2.Text) & ""
rs.Open strsql, conn, 3, 3
If rs!甲方 = Val(Text2.Text) Then
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXX
Else
MsgBox ("不存在此记录")
Text2.Text = ""
XXXXXXXXXXX
XXXXXXXXXXXXXXXXXX
Exit Sub
End If
End If
End If
End Sub
