954,566 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

query a date format within an input box

Hi folks

This will be my first ask for help here;)

I'm working on a database at the moment and have exhausted my resources on this one.

I have a report with an underlying muti-table query. The report uses an input box to set the date criteria rather than Parameter boxes to show the relevant records from to these dates.

and then I've used

Between [Forms]![frmMonthlyDisbursalDialog]![StartDate] And [Forms]![frmMonthlyDisbursalDialog]![EndDate]


within the query to reference to the dates seleted within the input box All is working well here.

My question is. If I wanted to use just the Month and Year as criteria, so that I would, perhaps, just have a drop down month combo box and a control for the year. Is it possible to extract the records for that month rather than typing in the exact date to that day?. Or maybe something similar to this technique?

All my other attemps have failed. Hope someone can help.

pablavo
Newbie Poster
6 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
 

Hi,

The easiest way is using the function DateSerial so that it would look like Between DateSerial([Forms]![frmCriteria]![txtFrmYr],[Forms]![frmCriteria]![comFrmMth],1) And DateSerial([Forms]![frmCriteria]![txtToYr],[Forms]![frmCriteria]![comToMth],1) . I have included an example that demonstrates this case, hope it is what you are looking for.

Attachments Sample.zip (20.88KB)
kb.net
Junior Poster
172 posts since Aug 2007
Reputation Points: 13
Solved Threads: 29
 

Kb.Net wrote
The easiest way is using the function DateSerial so that it would look like

That's brilliant Kb.net! thankyou! I just have one more question. If I use use the input box and put Dec 2006 to Jan 2007 will that just give me the month of December without pulling records from January?

Thanks again.

pablavo
Newbie Poster
6 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
 

Ah, Ok it gives me the first day of the "To Month" and then I place a minus 1 " -1)" like so, and that takes away the first day of the "To Month.

Between DateSerial([Forms]![frmCriteria]![txtFrmYr],[Forms]![frmCriteria]![comFrmMth],1) And DateSerial([Forms]![frmCriteria]![txtToYr],[Forms]![frmCriteria]![comToMth],1-1)


Great!

pablavo
Newbie Poster
6 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
 

Hello. I'm working on a similar project. Is it possible to have the results returned in another form, Rather than a report? I want to do a Date range search and then be able to edit the data in my resulting records. Thanks

Milster
Newbie Poster
1 post since Jan 2008
Reputation Points: 10
Solved Threads: 0
 
Hello. I'm working on a similar project. Is it possible to have the results returned in another form, Rather than a report? I want to do a Date range search and then be able to edit the data in my resulting records. Thanks


Yes, you would do similar to what was shown for the report but base the criteria of the recordsource of the other form as shown above.

boblarson
Junior Poster in Training
79 posts since Jan 2008
Reputation Points: 31
Solved Threads: 8
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: