Solved

Parameter Query with wildcard

Posted on 2013-05-25
10
371 Views
Last Modified: 2013-05-25
Hi,
I have this parameter query Like "*" & [Date] & "*"

I would like to be able to add a date range. Unfortunately I can't use the standard Between - And parameter because my data is from a linked table that has the date and time in the field.

Thanks,
Ward
0
Comment
Question by:draw58
10 Comments
 
LVL 33

Expert Comment

by:Norie
ID: 39196596
Ward

What dates are you actually looking for?
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39196600
If you need to do a Date range comparison (user inputs the range), without the time portion, then switch to SQL View and use this for the WHERE clause of your query:

WHERE DatePart([YourDateTimeFIeld]) BETWEEN [Start Date] AND [End Date]
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39196651
personally, i would recommend using

"where [datefield] >= #" & [from date] & "# and [date field] < #" & dateadd("d", 1, [thru date]) & "#"
0
 

Author Comment

by:draw58
ID: 39196684
This is my SQL. I am getting an error "Wrong number of arguments used with function in query expression.

SELECT [Sales History].TKT_NO, [Sales History].TKT_DT, [Sales History].SLS_REP, [Sales History].STR_ID, [Sales History].ITEM_NO, [Sales History].DESCR, [Sales History].CATEG_COD, [Sales History].QTY_SOLD, [Sales History].EXT_COST, [Sales History].EXT_PRC, [Sales History].PRC_OVRD_REAS, [Sales History].NAM, [Sales History].CUST_NO, [Sales History].EMAIL_ADRS_1, [Sales History].NAM1, [Sales History].ITEM_VEND_NO, [Sales History].SUBCAT_COD, [Sales History].PRC_1, [EXT_PRC]-[EXT_COST] AS PROFIT, ([EXT_PRC]-[EXT_COST])/[EXT_PRC] AS [Profit Percent]
FROM [Sales History]
WHERE DatePart([TKT_DT]) BETWEEN [Start Date] AND [End Date]
0
 
LVL 77

Expert Comment

by:peter57r
ID: 39196689
The function should be DateValue() not DatePart()
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

Author Comment

by:draw58
ID: 39196734
I get "data type mismatch" when i switch to DateValue
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39196740
Do you have nulls in your data?

Try

DateValue(nz(yourdatefield, #1/1/1900#))
0
 

Author Comment

by:draw58
ID: 39197123
Nope, I don't have any nulls. Where do I put DateValue(nz(yourdatefield, #1/1/1900#)) ?
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 39197137
Try this:


SELECT [Sales History].TKT_NO, [Sales History].TKT_DT, [Sales History].SLS_REP, [Sales History].STR_ID, [Sales History].ITEM_NO, [Sales History].DESCR, [Sales History].CATEG_COD, [Sales History].QTY_SOLD, [Sales History].EXT_COST, [Sales History].EXT_PRC, [Sales History].PRC_OVRD_REAS, [Sales History].NAM, [Sales History].CUST_NO, [Sales History].EMAIL_ADRS_1, [Sales History].NAM1, [Sales History].ITEM_VEND_NO, [Sales History].SUBCAT_COD, [Sales History].PRC_1, [EXT_PRC]-[EXT_COST] AS PROFIT, ([EXT_PRC]-[EXT_COST])/[EXT_PRC] AS [Profit Percent]
FROM [Sales History]
WHERE DateValue(nz([TKT_DT], #1/1/1900#)) BETWEEN CDate([Start Date]) AND CDate([End Date])

Open in new window

0
 

Author Closing Comment

by:draw58
ID: 39197249
Perfect! Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now