Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
| Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA 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 September 22nd, 2009, 06:56 AM
Friend of Wrox
Points: 718, Level: 10
Points: 718, Level: 10 Points: 718, Level: 10 Points: 718, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: Ennis, Clare, Ireland.
Posts: 131
Thanks: 10
Thanked 0 Times in 0 Posts
Default return recordset using 'Like' Operator

Using excel 2003

Hi,

I'm trying to return a recordset using the 'LIKE' operator. In the example below, strFilter is a textbox value.

Code:
 
rs.Open "SELECT * FROM qryAccountSetup WHERE ProgramTypeId = " & intId & " AND (AccountNo Like '" & strFilter & "') ORDER BY AccountNo", co, adOpenForwardOnly, adLockReadOnly
If strFilter = '00001' then a value is returned from the recordset.
If strFilter = '0000*' then the recordset is empty.

What is the correct syntax when using 'LIKE'?
Can anyone help please?

Thanks in advance,
__________________
Neal

A Northern Soul

Last edited by Neal; September 22nd, 2009 at 06:59 AM..
 
Old September 22nd, 2009, 07:14 AM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: India
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Try using:
Code:
rs.Open "SELECT * FROM qryAccountSetup WHERE ProgramTypeId = " & intId & " AND (AccountNo Like '%" & strFilter & "%') ORDER BY AccountNo", co, adOpenForwardOnly, adLockReadOnly
__________________
Om Prakash Pant
Click the "Thanks" button if this post helped you.
The Following User Says Thank You to om_prakash For This Useful Post:
Neal (September 22nd, 2009)




Similar Threads
Thread Thread Starter Forum Replies Last Post
Using ADO to Return Recordset Error ms2sf BOOK: Excel 2007 VBA Programmer's Reference ISBN: 978-0-470-04643-2 2 May 25th, 2009 04:16 PM
Return Recordset from Stored Procedure? WildRover SQL Server 2000 8 March 23rd, 2009 08:17 AM
Can i return a recordset in a Stored procedure chiefouko VB Databases Basics 6 December 12th, 2006 03:34 AM
Use of return operator. PC BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 3 July 1st, 2005 09:54 AM
Can i return a recordset in a Stored procedure chiefouko SQL Server 2000 1 June 23rd, 2003 06:13 AM





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