Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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 February 25th, 2010, 04:41 PM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 131
Thanks: 10
Thanked 0 Times in 0 Posts
Default Use of Wildcard as parameter in query

Hi,

I'm using Access 2003 and am passing a parameter in a query which is used as the record source of a report.

One of the options a user can select is 'ALL' which passes the 'Like *' code to a string which is then referred to by the parameter.

I have tried a number of different methods:

Code:
 
strPeriodParam = " Like "*""
 
strPeriodParam = Chr(32) & Chr(76) & Chr(105) & Chr(107) & Chr(101) & Chr(32) & Chr(34) & Chr(42) & Chr(34)
(The 2 examples are the same when debugging)

either is then passed to the following function:

Code:
Public Function ParameterPeriod()
    ParameterPeriod = strPeriodParam
End Function
The ParameterPeriod() is used in the specific query column. But the (report) output is NOT displaying any results. However, if I manually enter 'Like *', then it does produce results.

Any ideas Please?

Thanks in advance,
__________________
Neal

A Northern Soul
 
Old February 26th, 2010, 04:07 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 131
Thanks: 10
Thanked 0 Times in 0 Posts
Default

Hi again,

I finally worked it out... it was simple (these things usually are). Firstly:

Code:
strPeriodParam = "*"
Then, within the Query, I typed the following in the Criteria row of the applicable field:

Code:
Like ParameterPeriod()
The function was left as in the original posting.

Thanks anyway,
__________________
Neal

A Northern Soul

Last edited by Neal; February 26th, 2010 at 04:09 AM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing wildcard parameter to Dataadapter Hughesie78 ASP.NET 2.0 Professional 0 July 3rd, 2008 02:30 AM
Parameter Query Teqlump Access 4 November 11th, 2004 07:21 PM
ADO Query kills the Wildcard in LIKE stmt Vanaj Access 2 April 1st, 2004 11:31 AM
Wildcard characters in query giving trouble programmer_kay ADO.NET 3 March 21st, 2004 10:04 PM
Parameter Query Ben Access VBA 1 June 27th, 2003 12:13 PM





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