Hallo to all, can anyone help me how to display data from the database based on the date from the dtpicker? In my database I have a column date and a column event, if I click a particular date in the dtpicker it should display in the MSFlexGrid the date and the event if it exist in the database, if not then the MSFlexGrid will remain blank. . .

Please help me with this, or can anyone give me a sample program with this as reference. . .thank you so much to all.

Recommended Answers

All 12 Replies

Please help me, this is for my thesis . .email me at [email removed] for sample program. . . thank you so much.

The dtpicker there is known as calendar or month view in VB 6

why you are using calender or month view.....???
its just a matter of selecting a date only...you can easily use the date picker control in vb....there is already a one in there for your use....just add the Microsoft Windows Common Control 2 6.0 from components list and use the datepicker control....

well now for the coding part....
you can easily use datepicker to query your database to get data filtered by a selected date...but the coding differs on the nature of the database...

if you use any local database like "msaccess", the sql should be-->

"select * from <table name> where doj=#" & format(dtpicker1.value,"MM-dd-yyyy") & "#"

where "dtpicker1" is the name of your datepicker control...

if you use any server side rdbms like sql server or oracle, the sql should be :-

"select * from <table name> where doj='" & format(dtpicker1.value,"dd-MMM-yyyy") & "'"

now the choice is yours....try any one of these and get me a feedback if this works out...


thank you so much, i will try your solution, i will post here after 15hrs to let you know the result. Thank you so much.

so how will i display in the MSFlexGrid all the dates I selected in the dtpicker? if I choose 1/25/09, all 1/25/09 will display in the MSFlexGrid.

so how will i display in the MSFlexGrid all the dates I selected in the dtpicker? if I choose 1/25/09, all 1/25/09 will display in the MSFlexGrid.

okk...it seems that my last post was not in vain...wasn't it???

one thing i must ask you...why are you using msflexgrid to display data from database instead of using listview control.....though listview is the most flexible control than flexgrid and populating a lv rather than a fg is so much easy....just an asking...ultimately the choice is yours...

kkk....the following is a sample code you can use to populate a fg :-

rs.Open "select * from info order by website", gcn

MSGrid.Rows = 1
MSGrid.Cols = 2
[B]MSGrid.FormatString = "  Website    |   UserName   |   Password    |   Referenced By"[/B]

MSGrid.Rows = 1

If rs.RecordCount > 0 Then
    While Not rs.EOF()
        rowVal = rs!website & vbTab & rs!username & vbTab & rs!password & vbTab & rs!ref_id
        MSGrid.AddItem rowVal
End If

If rs.State = adStateOpen Then rs.Close
Set rs = Nothing

where rs is the recordset and gcn is the connection object respectively....you can replace these with your own...

the 1st line is the query to fetch data from your database....change the statement according to your suits....

look at the bolded line....this is string for creating headers for your flexgrid control....change this accordingly....

and finally...check the line marked in red....this is the string for constructing a row value for fg and finally inserting to the grid...

hope this might been useful in some context....try this out and get me your feedback...


thank you for the help, i'll give the feedback as soon as i can, thanks also for the advise. I will try listview.

you are welcome...
hv a nice day...

Hallo friend, can I ask a favor? Can I ask a sample program using your code? I really need a help with this, as you can see I am new to this that is why I can't visualize and understand that much some of your thoughts. I can fully understand if see an actual output of your code. Please, thank you my friend.

what are the limitation of using ms Access to connect to database
am creating my first project in vb 6 and connecting to the database using the data control.what challenges am i likely to encounter?

what if the data needed is from 2 different table? * is for all fields right?

I am getting compiling error code424: Object Required
I am using VB6.0 and Access Database.mdb

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.