Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 30th, 2004, 06:55 AM
Authorized User
 
Join Date: Jun 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Perform SQL multi-filtering in VB

How can I do this in VB?

I want to perform two filter conditions in my SQL recordset...how do I state this in one uniform statement...I am new to SQL syntax so I'm not sure how to combine the two statments into one.
Right now I just have two .filter statments, one after another in my VB code. It seems it is performing the filtering tusing only the last filter statment.


Thanks,
Maria
 
Old July 30th, 2004, 07:59 AM
Authorized User
 
Join Date: Jul 2004
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default

make one filter using the AND operator

here is the example from the help

(LastName = 'Smith' AND FirstName = 'John')

David
 
Old July 30th, 2004, 08:42 AM
Authorized User
 
Join Date: Jun 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It does not work like this...well I have a variable called temp and an actual number to compare: the number 2. I have tried a few different combinations but they don't seem to work:

temp = rstMacroData!MacroName 'Get the name from another recordset

' None of the statements work!
rstBookmarks.Filter = "MacroName = temp And DOCT_ID = 1"
rstBookmarks.Filter = (MacroName = temp And DOCT_ID = 1)
rstBookmarks.Filter = "MacroName = " & "'" & temp & "'" AND "DOCT_ID = 2"

Do you know how to do it? It seems pretty simple but I just don't what combination of ',",(,) that works!

Thanks again!
Maria

 
Old August 2nd, 2004, 04:35 AM
Authorized User
 
Join Date: Mar 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this one:

rstBookmarks.Filter="MacroName=""" & temp & """ AND DOCT_ID=1"


Lucian Preda
[email protected]
 
Old August 4th, 2004, 09:50 AM
Authorized User
 
Join Date: Jun 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the help. Just a little more tweaking and this did the job:

 rstBookmarks.Filter = "MacroName= " & "'" & temp & "'" & " AND DOCT_ID=1"





Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL "WHERE" Statement Boolean filtering Nostromo77 ASP.NET 2.0 Basics 2 May 27th, 2008 11:09 AM
C# and SQL express 2005, multi-user access ?? Boudy C# 2005 4 February 27th, 2007 04:43 AM
multi-multi-multiple Insert with subquery??? jmjyiannis SQL Server 2000 1 May 5th, 2006 02:20 PM
Connection cannot be used to perform this operatio LibrarianMo Access ASP 1 February 24th, 2006 01:18 PM
Using common .vb code in multi projects ocarroll .NET Framework 2.0 5 August 17th, 2004 04:38 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.