Opening Form To A Specific Record

G

Guest

I have a form called EMPLOYEE LOG, and I want it to open up to a date that is
entered by the user. I have a form called DATE ENTER, in which the user
would type in the date and it will open up EMPLOYEE LOG to that date. It
works perfectly fine, but my problem is that method I used creates a filter
and the NEXT RECORD and the PREVIOUS RECORD buttons don't work because there
is only one record in the form (because of the filter). I know that a filter
can be removed by either DoCmd.ShowAllRecords or Me.FilterOn = False. I
placed the Me.FilteOn= False just above the code for my NEXT RECORD
button(DoCmd.GoToRecord , , acNext), my problem with that is that when it
removes the filter it jumps to the first record. I would instead want it to
continue from the record it is on.

For example: The user enters in Jan 11 2005 in the DATE ENTER form and
presses the open button which opens the EMPLOYEE LOG form on the date Jan 11
2005. When the user presses the Next button, it goes to Jan 03 2005.
Instead of Jan 12 2005.

Maybe the method that I am using is wrong, if anyone has any suggestions let
me know. My form has in 260 records and I was trying to find the easiest way
to allow the user to go directly to the record he/she wants and still be able
to go to the records before and after it.
 
P

Penguin

Try this code in the AfterUpdate of the Date Enter forms text box:

DoCmd.OpenForm "Employee Log"
Forms![Employee Log].RecordsetClone.FindFirst "[txtDate] = #" & _
Me![txtDate] & "#"
Forms![Employee Log].Bookmark = Forms![Employee _
Log].RecordsetClone.Bookmark
DoCmd.Close acForm, "Enter Date"

Replace txtDate with your control name.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top