[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 848
  • Last Modified:

How to filter a CurrentDb.OpenRecordset?

The filter that I am using, see below, has no affect.  That is, the result is the same with or without the filter statements.  In the example, below, I'm trying to gather all records whose CustIDs are 707.  (in the final code, 707 would be a variable, but I'm now using a constant for testing)

With CurrentDb.OpenRecordset("Tabletbl1", dbOpenDynaset)
         .Filter = "[CustIds]= 707"  
         rsFiltered = OpenRecordset
             .
             .
             .
    End With

Again, works fine.  But, is ignoring the filter.  What am I doing wrong?

MichaelDJ
0
MichaelDJ2000
Asked:
MichaelDJ2000
  • 3
1 Solution
 
Mike EghtebasDatabase and Application DeveloperCommented:
use:

Set rs= CurrentDb.OpenRecordset("Select * From Tabletbl1 Where [CustIds]= 707", dbOpenDynaset)

Btw, tomorrow I will be able to take a look at you other question you sent.

mike
0
 
Mike EghtebasDatabase and Application DeveloperCommented:
or,

Dim MyVal As Long

MyVal=707

Set rs= CurrentDb.OpenRecordset("Select * From Tabletbl1 Where [CustIds]=" & MyVal, dbOpenDynaset)

0
 
MichaelDJ2000Author Commented:
egtebas

Thanks.  Worked great!

As you can see, i'm learning as i go  (sink or swim)

Looking forward to your results on the previous question.

Also, is there a good Visual Basic Access reference book that you can recommend?   I'm looking for a book that has a listing and description of the commands/statements.  Have not had any luck finding such a book.  (Based on my questions, you might have an idea of a book that might help)

MichaelDJ
0
 
Mike EghtebasDatabase and Application DeveloperCommented:
Mastering Access (CD by examples) is what I have used in early 1990s.  I don't know very many books on this subject.  Generally, QUE has good books on all subjects.  I whish we hade EE way back in 90s when I started learning Access.

Thank you for the grade.

Mike
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now