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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open a record from an index so that it is not in a filtered view

Status
Not open for further replies.

bhunter

Programmer
Jul 27, 2000
36
US
I have a database that has a main index with a list of records that correspond to forms that can be opened. For example, I go to the 12th record in the index and hit a button and the 12th record form is opened. The problem however, is that the form is opened in filtered view. I have buttons on the form to go to the previous or next records. In filtered view I cannot use these buttons. Is there a way to go to a form so that it is not in filtered view?

[sig][/sig]
 
You say that you &quot;hit a button&quot; and go to the 12th form. It sounds like you are on some kind of a for which has command buttons on it. Could you post the code behind the command button? To get to the code, open the form in design view, right click on the button and choose Build Event from the popup menu. [sig]<p>Kathryn<br><a href=mailto: > </a><br><a href= > </a><br> [/sig]
 
Hi,
Try removing the filter in code. I don't know the exact code to do this (as I have never had to do this) but you can probably do it with a DoCmd.DoMenuItem call. Also, I believe that when you remove the filter on a form, the form resets back to the first record, therefore you will need to grab the current records unique value first, remove the filter, and then move the forms recordset or bookmark back to the last record.
Rob Marriott
CCTC1
rob@career-connections.net [sig][/sig]
 
Here is the code for the button...

Private Sub Open_selected_procedure_Click()
On Error GoTo Err_Open_selected_procedure_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = &quot;Test Procedure Form&quot;

stLinkCriteria = &quot;[Test ID]=&quot; & &quot;'&quot; & Me![Test ID] & &quot;'&quot;
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Open_selected_procedure_Click:
Exit Sub

Err_Open_selected_procedure_Click:
MsgBox Err.Description
Resume Exit_Open_selected_procedure_Click

End Sub

As you can see, I am opening the form with certain constraints. It is basically matching an ID that I have on the index with an ID on the form. [sig][/sig]
 
Hi,
Remove the filter with the appropriate code, then use the following code to return to the record that was displayed before the form was requeried (as a result of the removal of the filter).

MyVariable = Forms![MyForm].[Test ID]

remove filter code goes here....

Forms![MyForm].RecordsetClone.FindFirst &quot;[Test ID] = '&quot; & MyVariable & &quot;'&quot;

Forms![MyForm].Bookmark = Forms![MyForm].RecordsetClone.Bookmark

That should work.
Rob Marriott
CCTC1
rob@career-connections.net [sig][/sig]
 
Is there a way to automatically insert data, pre-selected from a subform, into the text field in the find record dialogue and automatically start searching? The user would select the record to open in the list, and then click the find button. The find dialogue box opens with the selected record ID and searches through the database for the record. [sig][/sig]
 
Thanks for the code Rob. I am trying it out right now. I will let you know how it works. [sig][/sig]
 
It worked!! I got the code to do exactly what I needed it to do. Thanks a million! I do have one question about it though. When I do a recordset clone and bookmark does it increase the size of my database file? I don't want my database to grow if I keep running this procedure. [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top