我在这里学编程应用篇 共45页[1 2 3 4 5 6 7 >»<... 最后一页]

数据库查询示例

数据库查询示例

Private Sub Command1_Click()
On Error GoTo OOPS
Dim My_Query As String



MyQuery = Cbo_Category & " " & Cbo_Operator & " '" & Text1.Text & "'"

Data1.RecordSource = "SELECT * FROM Customers WHERE " & MyQuery

Data1.Refresh


Data1.Recordset.MoveLast: Data1.Recordset.MoveFirst
MsgBox Data1.Recordset.RecordCount & " matches found."
Exit Sub
OOPS:
MsgBox "No Records Found"
End Sub

Private Sub Form_Load()
MsgBox "If you use the LIKE method, then you can use the *(wildcard) to complete the query." & vbNewLine & "Like do a search for Ma* or M*ria or *m* etc."
With cdgPath
.Filter = "数据库文件(*.mdb)|*.mdb"
.ShowOpen
End With
Data1.DatabaseName = cdgPath.FileName
Cbo_Category.ListIndex = 0
Cbo_Operator.ListIndex = 0
End Sub
 

我在这里学编程应用篇 共45页[1 2 3 4 5 6 7 >»<... 最后一页]