Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Datepicker (newbie)

Status
Not open for further replies.

salchris

Programmer
Oct 25, 2003
3
US
Ladies and Gentleman,
Just found this site, and after surfing for an hour or so, decided I really needed to ask where I can get tutorial on using the datepicker. I have an app that calls for the end user to select dates from 2 pickers, it needs to search Access for those persons who fall in that date range. I looked in MSDN for a tutorial, but alas found none. Anyones help would be greatly appreciated. Point me in the right direction is all I ask
Cheers
salchris

Writing Code is like faking an orgasm, with enough practice even I can do it
 
Getting the dates from the pickers is trivial:

[tt]
Dim dtStart As Date
Dim dtEnd As Date

dtStart = CDate(dtpStart.Value)
dtEnd = CDate(dtpEnd.Value)
[/tt]

Then you can just create a SQL string to get your recordset with:
[tt]

Dim rst As DAO.Recordset
Dim strSQL As String

strSQL = "SELECT * FROM myTable WHERE HireDate BETWEEN #" & dtStart & "# AND #" & dtEnd & "#"

Set rst = CurrentDb.OpenRecordset(strSQL)

With rst
While Not .EOF
Debug.Print .Fields("HireDate")
.MoveNext
Wend
End With

[/tt]



VBSlammer
redinvader3walking.gif

[sleeping]Unemployed in Houston, Texas
 
Thanks Slammer,
I appreciate the help. I've been staring blankly at the monitor for what seems like hours. Whoa,, has been hours.
Again thx for you help
salchris


Writing Code is like faking an orgasm, with enough practice even I can do it
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top