Hi Jim,
The problem is that I want the form to open to a specific record, but then I want the user to be able to move to other records. I've tried using the following code and it won't work for some reason:
If ActiveSheet.AutoFilterMode Then
ActiveSheet.AutoFilterMode = False
End If
Any suggestions?
Thanks,
Kira
Hi,
This is probably pretty clunky (I haven't had my second coffee yet) but...
The button on the form which opens the target form should have something like this
- Private Sub btnOpen_Click()
-
Dim strSearch As String
-
strSearch = "Surname = '" & Me.txtSearch.Value & "'"
-
DoCmd.OpenForm "frmTarget", , , , , , strSearch
-
End Sub
where txtSearch is a text box on that form into which the operator types the person's name or whatever that you want the other form to open with. This opens the second form (frmTarget here but change the code to suit) and the strSearch after the long row of commas puts something like Surname = 'Smith' as the OpenArgs for the second form. OpenArgs (or Tag) is a handy way to pass information between forms, reports etc.
The second form should have in it's On Open event
- Private Sub Form_Open(Cancel As Integer)
-
Dim rsClone As DAO.Recordset
-
Dim strSearch As String
-
-
Set rsClone = Me.RecordsetClone
-
strSearch = Me.OpenArgs
-
rsClone.FindFirst strSearch
-
If Not rsClone.NoMatch Then
-
Me.Bookmark = rsClone.Bookmark
-
End If
-
End Sub
Which should do the trick. (you might want to put an Else clause in the If statement to show a message box explaining that the string wasn't found)
Jim
ps ActiveSheet etc is Excel stuff!