Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = New Connection → Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;" & _
"Data Source=F:\Access\database.mdb"
cn.Open
Set rs = New Recordset
rs.Open "table", cn, adOpenDynamic, adLockOptimistic, adCmdTablePublic Function find_str() As String
If Text1.Text = Empty & Text2.Text = Empty Then → If Text1.Text = Empty And Text2.Text = Empty Then
MsgBox "cannot be empty"
Form1.Text1.SetFocus
Else
find_str = "select * from table1 where col1='" _
& Form1.Text1.Text & "' or col2 = '" & Form1.Text2.Text & "'"
End If
End Function
Dim rs As ADODB.Recordset
Set cn = New Connection → Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;" & _
"Data Source=F:\Access\database.mdb"
cn.Open
Set rs = New Recordset
rs.Open "table", cn, adOpenDynamic, adLockOptimistic, adCmdTablePublic Function find_str() As String
If Text1.Text = Empty & Text2.Text = Empty Then → If Text1.Text = Empty And Text2.Text = Empty Then
MsgBox "cannot be empty"
Form1.Text1.SetFocus
Else
find_str = "select * from table1 where col1='" _
& Form1.Text1.Text & "' or col2 = '" & Form1.Text2.Text & "'"
End If
End Function
控件的前面都要加窗体的名称.