Simple search form using record selectors

ST4RCUTTER

Registered User.
Local time
Today, 02:59
Joined
Aug 31, 2006
Messages
94
Some of my users have asked that I create a simple search form that will let them view several fields for each record and then select the desired record using record selectors along the left edge of the form. Once clicked, I will use the Form_Click event to display the same record on the main form "frm_recordentry".

Simple enough task. The subform was easily created but I'm having trouble getting the FindFirst code to work. Again, my goal is to select the TaskID value using this search form and then find the first matching record on the form "frm_recordentry" and jump to it. I can then add code to automatically close the search form. Here is what I've been working with but I think my syntax is incorrect. I keep getting object not found errors so Access is not able to resolve the form object for "frm_recordentry"...at least that is what I think:

My code:

Code:
Private Sub Form_Click()

  ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.RecordsetClone
    rs.FindFirst "[Forms]![frm_recordentry]![TaskID] = '" & Me![TaskID] & "'"
    If Not rs.EOF Then [Forms]![frm_recordentry].Bookmark = rs.Bookmark
         
End Sub
 
You don't need a SEARCH form for this.
In "frm_recordentry" use FILTER BY FORM, CLEAR GRID, APPLY FILTER and REMOVE FILTER icons.
Look at attachment (word, zip).
 

Attachments

MStef,

Thank you for the reply and that information, but I do not want searches initiated from the main form. I know that Access is capable of doing this, but this is not the design I am pursuing.
 
It appears that on the Form_Click event I need to open the recordset of the search form and copy the recordset to variable rs. I then need to store the selected value, in this case it is the value of the field TaskID. Then I must clone the recordset of the other form frm_recordentry and search it using the stored value above. This is what I was thinking, but it's not working:

Code:
Private Sub Form_Click()

    Dim rs As Recordset, rst As Recordset, Tval As Integer
    [COLOR="Green"]'Select ID from search form using record selector[/COLOR]
    Set rs = Me.RecordsetClone
    Tval = Me.TaskID
    
    [COLOR="green"]'Search recordset of main form for value of Tval[/COLOR]
    Set rst = Forms!frm_recordentry.Recordset.clone
    rst.FindFirst [TaskID] = Tval
    If Not rst.EOF Then Forms!frm_recordentry.Bookmark = rst.Bookmark
End Sub

After clicking the record selector on the search form it does nothing. I was hoping that the record clicked on the search form would be the one selected on frm_recordentry. Again, I am searching this way so I can show all records on the search form at one time and then let the user simply click a record selector to jump to the next record.
 

Users who are viewing this thread

Back
Top Bottom