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 18th, 2005, 10:39 AM
Authorized User
 
Join Date: Jan 2005
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default Add default value to a parameter in a query

This is my code in the criteria in my query:

>=Date()-[Enter Days Back:]

Is there any way of setting a default value of lets say 30. If not what can I do?

 
Old February 18th, 2005, 04:37 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Hi,

   You can do this by taking the parameter statemenet out of your query, and then using a button that calls an InputBox instead of the vb dialog box that the query uses:

For the button's On Click:
'==========
Dim strDays As String (or Long?)

strDays = InputBox("Enter Days Back:", vbOkOnly, "Caption")

IfIsNull(strDays) Then
   strDays = "30+ (or 30 if it is an integer)
End If

'then put your code to call the query or report using strDays
' in your link
' "[Days] = " & "'" & strDays & "'"
'or "[Days] = " & strDays if it is an integer
'==========

I think that should work.

HTH


mmcdonal
 
Old February 18th, 2005, 04:39 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Sorry, that should be

strDays = "30"

not

strDays = "30+

mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 6 error: Parameter.. .has no default value ikaminow BOOK: Beginning VB.NET Databases 1 July 27th, 2007 07:39 AM
select all by default for parameter roy_mm Reporting Services 1 March 30th, 2007 03:48 PM
how do i set default parameter value.. rupen Classic ASP Basics 5 January 5th, 2007 12:14 AM
Change default date parameter format JeffHickman Reporting Services 0 February 14th, 2006 06:52 AM
how to set parameter default value oranginalab Classic ASP Basics 0 August 28th, 2003 02:53 AM





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