By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,677 Members | 1,218 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,677 IT Pros & Developers. It's quick & easy.

Having trouble listing car-makes starting with the letter "d"

P: n/a
MLH
Am having trouble with the filter property setting below.
Would like to filter the listing to car makes beginning
with "D". I'm blowing it on the filter spec somehow???

Sub OpenRecordsetX()

Dim MyDB As Database
Dim rstTemp As Recordset
Dim rstTemp2 As Recordset
Set MyDB = CurrentDb()

' Open several different Recordset objects and display the
' contents of each.

Debug.Print "Opening forward-only-type recordset " & _
"where the source is a QueryDef object..."
Set rstTemp = MyDB.OpenRecordset( _
"qryAuthsNvehics", dbOpenForwardOnly)
OpenRecordsetOutput rstTemp

Debug.Print "Opening read-only dynaset-type " & _
"recordset where the source is an SQL statement..."
Set rstTemp = MyDB.OpenRecordset( _
"SELECT * FROM tblAutoMakes", dbOpenDynaset, dbReadOnly)
OpenRecordsetOutput rstTemp

' Use the Filter property to retrieve only certain
' records with the next OpenRecordset call.
Debug.Print "Opening recordset from existing " & _
"Recordset object to filter records..."
rstTemp.Filter = "Make = 'Like D*'"
Set rstTemp2 = rstTemp.OpenRecordset()

OpenRecordsetOutput rstTemp2

Debug.Print "Opening dynamic-type recordset"
Set rstTemp = MyDB.OpenRecordset("SELECT * FROM
PrecisionTuneContacts", dbOpenDynamic)
OpenRecordsetOutput rstTemp

rstTemp.Close
MyDB.Close

End Sub

Apr 10 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Br
MLH wrote:
Am having trouble with the filter property setting below.
Would like to filter the listing to car makes beginning
with "D". I'm blowing it on the filter spec somehow???

Sub OpenRecordsetX()

Dim MyDB As Database
Dim rstTemp As Recordset
Dim rstTemp2 As Recordset
Set MyDB = CurrentDb()

' Open several different Recordset objects and display the
' contents of each.

Debug.Print "Opening forward-only-type recordset " & _
"where the source is a QueryDef object..."
Set rstTemp = MyDB.OpenRecordset( _
"qryAuthsNvehics", dbOpenForwardOnly)
OpenRecordsetOutput rstTemp

Debug.Print "Opening read-only dynaset-type " & _
"recordset where the source is an SQL statement..."
Set rstTemp = MyDB.OpenRecordset( _
"SELECT * FROM tblAutoMakes", dbOpenDynaset, dbReadOnly)
OpenRecordsetOutput rstTemp

' Use the Filter property to retrieve only certain
' records with the next OpenRecordset call.
Debug.Print "Opening recordset from existing " & _
"Recordset object to filter records..."
rstTemp.Filter = "Make = 'Like D*'"
Set rstTemp2 = rstTemp.OpenRecordset()

OpenRecordsetOutput rstTemp2

Debug.Print "Opening dynamic-type recordset"
Set rstTemp = MyDB.OpenRecordset("SELECT * FROM
PrecisionTuneContacts", dbOpenDynamic)
OpenRecordsetOutput rstTemp

rstTemp.Close
MyDB.Close

End Sub


If it were me I'd just amend the SQL to include a WHERE clause....

SELECT * FROM tblAutoMakes WHERE Make Like "d*"

--
regards,

Br@dley
Apr 10 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.