Remove filter without loosing focus

A

Access::Student

Hi, I've got an issue that I can't figure out.

I've got a button on a form that I created using the button wizard that has
the following code:

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "PEOPLE"
stLinkCriteria = "[kp_people_id]=" & Me![kf_from_id]
DoCmd.OpenForm stDocName, , , stLinkCriteria

This just takes me to the related Form in People. the problem I've got is
that it applies a filter to people and only show's one record. I want it to
show all. I've tried using "DoCmd.ShowAllRecords" but I lose my current
record if I do that. Is there a better way? I want to be able to click the
button, go to the other form, and be on the record I want but with no filter
present.
 
D

Dirk Goldgar

Access::Student said:
Hi, I've got an issue that I can't figure out.

I've got a button on a form that I created using the button wizard that
has
the following code:

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "PEOPLE"
stLinkCriteria = "[kp_people_id]=" & Me![kf_from_id]
DoCmd.OpenForm stDocName, , , stLinkCriteria

This just takes me to the related Form in People. the problem I've got is
that it applies a filter to people and only show's one record. I want it
to
show all. I've tried using "DoCmd.ShowAllRecords" but I lose my current
record if I do that. Is there a better way? I want to be able to click the
button, go to the other form, and be on the record I want but with no
filter
present.


Try code like this:

'----- start of code -----
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "PEOPLE"
stLinkCriteria = "[kp_people_id]=" & Me![kf_from_id]

DoCmd.OpenForm stDocName
Forms(strDocName).Recordset.FindFirst strCriteria

'----- end of code -----
 

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