Sub SeekByPrice(curPrice As Currency)
Dim db As Database
Dim rec As Recordset
Dim strSQL As String
strSQL = "tblSales"
Set db = CurrentDb()
Set rec = db.OpenRecordset(strSQL)
rec.Index = "AmountPaid"
rec.Seek "=", curPrice
If rec.NoMatch = True Then
Debug.Print "No orders cost " & FormatCurrency(curPrice)
Else
Debug.Print "Order No. " & rec("SalesID") & " placed on " & _
FormatDateTime(rec("DateOrdered"), vbLongDate) & _
" cost " & FormatCurrency(rec("AmountPaid"))
End If
rec.Close
End Sub
|