ms-access


Calculating days between dates and parameters in MS Access


I'm trying to write a query that allows me to get records for all users whose items are more than X number of days overdue. I want to be able to specify whether that number be 30 or 40 or 50. I am able to get the results I need when I specify a specific number in the sql query:
SELECT USER_TRANSACTIONS.PATRON_ID, USER_TRANSACTIONS.CURRENT_DUE_DATE,
DateDiff("d",USER_TRANSACTIONS.CURRENT_DUE_DATE,Date()) AS Expr1
FROM USER_TRANSACTIONS
WHERE (DateDiff("d", USER_TRANSACTIONS.CURRENT_DUE_DATE, Date()))>50
However, when I try to use a parameter in place of the number, 50. And then type in the number 50 when I run the query and am prompted
SELECT USER_TRANSACTIONS.PATRON_ID,USER_TRANSACTIONS.CURRENT_DUE_DATE,
DateDiff("d",USER_TRANSACTIONS.CURRENT_DUE_DATE,Date()) AS Expr1
FROM USER_TRANSACTIONS
WHERE (DateDiff("d", USER_TRANSACTIONS.CURRENT_DUE_DATE, Date()))>[MinimumNumDays]
The query gives me everything instead of limiting the records to those overdue by more than 50 days. What am I missing??
You will need to add [MinimumNumDays] as an Integer query parameter. (Click [?] Parameters on the upper right the query builder)
if you are running this query from a form you can add an unbouand text box to the form. Enter the number of days in this. In query definition right click on in the criteria row for Expr1 and select build, locate your text box in
forms -> Loaded Forms -> your form
double click on it and click OK

Related Links

Composite Key in MS Access 2003
Access 2007 response time
MS Access VBA DoCmd.ApplyFilter IsNull() evaluating false
Access 2010 Query pulling data that matches a label value
How to find broken queries in Access?
Hand Install of 64-bit MS Access ODBC drivers when 32-bit Office is present
How to insert values into an Access table's AutoNumber field?
java connecting to access database problem
How do you connect MS Access Database which is located on a file hosting site using VB6.0?
Can I add a button in an Access stock program to search Outlook?
Access 2000 Calling Append Query through GUI
Access 97 creating object from VB
Connection string for Access 2010
Data in Combo Box in form not relfecting in Access Report
Error with Access Stored Query that uses VBA Modules from excel
Failure creating Access database from TFS 2010

Categories

HOME
ms-access
java
compiler-construction
multithreading
asp.net-core
isabelle
fme
adb
paw-app
c#-2.0
callback
disassembler
retrofit
fancybox
android-youtube-api
cross-validation
primary-key
dacpac
correlation
size
netflix
uitypeeditor
pc
undefined
ab-testing
text-rendering
swingx
arabic
mustache.php
format-specifiers
sparse-matrix
facet
semantic-analysis
kannel
entitlements
linkerd
windows-error-reporting
quote
instant-messaging
r-raster
oracle-fusion-middleware
google-qpx-express-api
fog
perlin-noise
ghost4j
http-referer
devextreme
libvpx
abstract-class
lumberjack
broadcastreceiver
pdf-reactor
reportingservices-2005
total-commander
flashair
long-polling
flickr-api
taffy
hibernate-tools
strptime
revapi
atomicity
jlink
veracode
mu
git-diff
aurelia-validation
kbuild
font-size
flutterwave
bind9
crosswalk-runtime
word-vba-mac
medium.com
angular-cache
asp.net-4.5
ready-api
hexdump
bluemix-app-scan
tform
associative-array
energy
historian
vhd
srand
lib.web.mvc
pundit
interrupted-exception
key-management
geonetwork
dia
camanjs
phalanger
cctv
asp.net-web-api-odata
java-metro-framework
project-planning
p4java
poller
kgdb
message-driven-bean
mysqltuner
ora-00911
html4
chronoforms
mqx
quickdialog
amazon-appstore
nsdatecomponents
fireworks
xmlspy
javax.script
coda-slider
sproutcore-2
xsdobjectgen
nerddinner

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App