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

How to build the search form in ms-access
MS Access 2007 3044 Error
Assigning a Keyboard shortcut to a button in an Access 2007 form
ShellExecute() returns error code 5 when trying to open mdb file >10MB
Disable Check Box Based on Other Values
creating a server project in vb6 and ms-access
MS Access Dropdown List/Combo Box
How to communicate between two instances of open MDB with same form?
In Access 2007 CSV Export: Disable Scientific Notation
How do you format date fields of a Union Query in MS Access?
Porting MS Access application
automatically query and convert access db table to excel using vbs
Preserving linked tables for Access DBs in same folder when the folder changes
Disable warning: You copied a large amount of data onto the clipboard
How to get the name of Constraint?
Specify mdw file in embedded connection string to another Jet mdb: possible?

Categories

HOME
webpack
c#-4.0
plone
relayjs
alfresco
infragistics
umd
indesign
designer
foselasticabundle
serilog
propel
pythonanywhere
excel-vba-mac
openedx
emulator
reverse-proxy
captiveportal
django-storage
fluentvalidation
dbclient
jspm
madlib
microsoft-chart-controls
stormpath
winrt-xaml-toolkit
lxd
rotational-matrices
reportbuilder
document.write
particles.js
android-tabhost
elmah
http-live-streaming
nomethoderror
scrollable
atomicity
rails-routing
alphabet
dotnetzip
recursive-datastructures
setter
redundancy
background-service
wdf
ctest
netmq
hsv
tcpserver
rtbkit
vhd
ora-00900
simple-framework
atk4
feedback
libressl
dukescript
unity3d-gui
operator-precedence
typekit
tt-news
dml
hippomocks
kgdb
picturefill
meteor-velocity
oam
sitemesh
ftps
cos
html4
padarn
android-screen-support
smtp-auth
http-unit
distutils
browser-detection
first-responder
pysimplesoap
automount
errai
hosts-file
punbb
eclipse-templates
lpeg
w3wp.exe
infrastructure
nsviewanimation
firefox-5
procedural-music
msdev

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