MonthCalendar and textbox

Hello all,

I do I get a monthcalendar control to populate a textbox, and when the textbox is populated make the textbox search the database for all the information on that date ?

I thank you in advance
Who is Participating?
maralansConnect With a Mentor Commented:
1.  Add a datagrid(dg) to your form.
2.  Add a button(btnSearch) to your form.
3.  Connect to your database and return a dataset.
4.  Bind the datagrid to the dataset.
5.  When you select a date on the calendar, the date will appear in the textbox.
6.  Hit the btnSearch and it will search your dataset and return records that match the value in the textbox and appear in     the datagrid.
7.  DOB in this example is Date Of Birth.

Imports System
Imports System.Data
Imports System.Data.Oledb

Public Class Form1
    Dim cs As String = "provider=microsoft.jet.oledb.4.0;data source =c:\members.mdb "
    Dim cn As New OleDb.OleDbConnection(cs)
    Dim da As New OleDb.OleDbDataAdapter(" Select * From CreditApplication", cn)
    Dim ds As New DataSet

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        dg.DataSource = ds.Tables(0)
    End Sub

    Private Sub Calendar_DateChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles Calendar.DateChanged
        Dim selectDate As Date = Me.Calendar.SelectionStart
        textbox.Text = selectDate
    End Sub

    Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        Dim DOB As String = "05/01/2006"

        Dim dv As DataView = ds.Tables(0).DefaultView

        dv.RowFilter = "DOB LIKE '%" + textbox.Text + "%' "

    End Sub

End Class

should work for both access and mySql
on calendar.change event
textbox.text = calendar selected value

on textbox text changed event
 searchDB(textbox.text) <~ call your function here

this will search everytime they change the date, so if you accidently choose the wrong will still search

abennett10Author Commented:
I don't see a selectedvalue attribute
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

abennett10Author Commented:
It was actually textbox.text = calendar.SelectionStart.ToShortDateString
I wasn't sure if you were using a custom control for the calendar, hence the non  specific methods....I was just trying to steer you towards the route of automating the procedure.  Good luck.
What kind of DB and how are you displaying the returned data?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.