Adding calendar in ms access and view the data of specific day by clicking the date

1k views Asked by At

I'm working on MS Access, using Northwind DB. I'm trying to to add a calendar in a form and link it with the dbo_orders table. such that i can retrieve how many orders made on particular day by clicking on the date in calendar.

Ex. Consider the dbo_Orders in Northwind DB. If I click on 11/11/1996 button in the calendar it should show what all the things happened on that particular day below. i.e on the same screen having two segments, one segment above has calendar and below that should show details of that particular day upon clicking specific date.

I need to work on this, Your solution would be appreciated.

Thank you.

1

There are 1 answers

0
Mark C. On BEST ANSWER

I'm going to tell you how to do it without telling you how to do it.

Anytime you want to capture some "event" you're going to have to write code for it (or a Macro, but I don't like 'em). Simple as that.

So, there are a number of events we can use to target this functionality. What makes the most sense, from reading your question, is the OnChange event for your search text box.

So, if I was going to target a text box to capture some event, I would view the Form in design view, right click the text box, select Properties, click on the Event tab, and select On Change (the [...] to the right side), and finally select Code Builder.

So, what do you want to do? You want to capture the Text in the text box (because select the date doesn't change the .Value of it, and use that essentially in the WHERE clause of a query (whether it's ApplyFilter or whatever)

In the Sub Routine for the Text##_Change() event, I would probably declare a Date variable, and do something like..

Private Sub Text0_Change()

Dim dateToSearch As Date

dateToSearch = CDate(Me.Text0.Text)

End Sub

With that variable, you can use it as a filter, use it in a query or inline SQL, or do whatever you want with it. Since you're using a split form, you can use Me.Filter and then apply the Filter.