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

Access not allowing users to delete rows
Printing pictures in Access Forms
printing a record
MS access mdb file has a “repair” status first time it is opened from Access 2007
Viewing ACCDB with Access 2010 runtime when Access 2007 is installed
is it possible to password protect ms-access 2007 file without encryption
Will an MS Access back-end for a client server application have transfer speed problems?
MS-Access, Bound Control on Form, Show user text, but record PK for that text
Access - Design change error message without attempting to make a change
VBA question: debug.print displays the correct data - how to get it out of Immediate window?
create a customised openFileDialog
access 2010 One form add information in table1 and table2
Trying to improve performance by removing DLookUp - Access 2007
MS ACCESS 2007 - Making a small pop form not full screen, when all other forms are full screen
How do I make a stored procedure in MS Access?
how to validate ms access textbox using button click event?

Categories

HOME
deployment
reflection
ngrx
plone
iot
relay
bpmn
routes
malloc
youtube-api-v3
rdf
electronics
yum
vifm
dax
rascal
nstableview
alignment
messages
saxon
invantive-sql
karma-jasmine
nodatime
predix
reverse-proxy
excel-2007
facet
selectedindexchanged
kannel
windows-error-reporting
xacml
opentype
kendo-datasource
google-cloud-nl
winrt-xaml-toolkit
catch-all
sequential
hexo
android-ble
overlap
sqlite2
webdriver-manager
sql-server-agent
vao
prolog-setof
rdfs
brightcove
webdriverjs
orthogonal
cubes
android-fonts
spring-android
slicknav
etsy
autorest
persist
energy
lemon
endeca-workbench
wordml
muse
appfabric-cache
flask-cors
marmalade
rtmfp
java.nio.file
cdc
gridfs
jmapviewer
mylyn
pygit2
kyotocabinet
first-responder
frameset
automount
onsubmit
qtkit
nsmanagedobject
hgsubversion
ecl
w3wp.exe
compiler-specific
simpletest
spec#
msdev
mdac

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