find record according to date

deepbreath

Registered User.
Local time
Today, 09:58
Joined
Apr 18, 2001
Messages
73
i want to search record in a specific period of time, i.e from one date to another date.
by entering the two dates in two text boxes.
 
If you want the information on a form then just set up a filter. Create a form with two textboxes(txtBeginDate and txtEndDate) and a command button. On Click of the command button, put the following code

if isnull(me("txtBeginDate")) then
msgbox "You must fill in a beginning Date."
exit sub
elseif isnull(me("txtEndDate")) then
msgbox "You must fill in an end date."
exit sub
else
docmd.openform "Your_Form_Name", , , "[DateField]>=#" & me("txtBeginDate") & "# AND [DateField]<=#" & me("txtEndDate") & "#"
end if

Hope that helps..

Doug
 
but i want to have a result in a new separate form, which displays the names of the required persons in datasheet view, or listbox will be just fine. and then on clicking any one of the list it will take to the main form for all details
 
can i use the same code to display the result in a subform already open, which gives you the list of the desired records
and also i base this search on a query
 
Yes you can use it for a subform... Just set the filter of the subform to the date criteria or set the recordsource to some SQL statement.

Filter:
Me!SubForm_Name.Form.Filter = "[DateField]>=#" & me("txtBeginDate") & "# AND [DateField]<=#" & me("txtEndDate") & "#"
Me!SubForm_Name.Form.FilterOn = True

SQL:
MySQL = "SELECT * FROM TableOrQueryName WHERE DateField>=#" & me("txtBeginDate") & "# AND DateField<=#" & me("txtEndDate") & "#"
Me!SubForm_Name.Form.recordsource = MySQL

Hope one of these solutions works for you.

Doug
 
a bit confused. i have two txtboxes for begining date and a end date and a subform below. and a command button, i enter the two dates and press the command button., what to put in click event and what in filter of subform?
 
Put this code in the Click event of the button...

Me!SubForm_Name.Form.Filter = "[DateField]>=#" & me("txtBeginDate") & "# AND [DateField]<=#" & me("txtEndDate") & "#"
Me!SubForm_Name.Form.FilterOn = True

And then you don't need anything in the filter of the subform... This code will set the filter after you click the button.

Doug
 
i don't know what to say, i can not get it right, can you send me a example
deepguru@hotmail.com
 

Users who are viewing this thread

Back
Top Bottom