C
Curtis Stevens
I have two boxes, Search by & Search For. Search by has the topic, such as
company name, then search for shows the records based on search by. When you
select it, it takes you to that record.
However, while back, it started become glitchy. Now, all of a sudden it
gives me this error message every so often:
The only way to fix it is to close the form and reopen it. I think
something changed while back, as it worked perfectly for a long time. I'm
running 2007 on Vista, but it was doing it before on 2002 on XP.
HERE IS MY CODE:
Private Sub SearchBy_AfterUpdate()
Me.SearchFor.RowSourceType = "Table/Query"
Me.SearchFor.RowSource = "SELECT DISTINCT [" & _
Me.SearchBy & "] FROM [" & _
Me.SearchBy.RowSource & _
"] ORDER BY [" & Me.SearchBy & "]"
End Sub
==========================================
Private Sub SearchFor_AfterUpdate()
On Error GoTo handler
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.Findfirst "[" & Me.[SearchBy] & "] = " & Chr(34) & Me![SearchFor] & Chr(34)
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Me.SearchFor = Null
handler:
If Err.Number = 3464 Then
rs.Findfirst "[" & Me.[SearchBy] & "] = " & Me![SearchFor]
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Me.SearchFor = Null
End If
End Sub
Thanks
Curtis
company name, then search for shows the records based on search by. When you
select it, it takes you to that record.
However, while back, it started become glitchy. Now, all of a sudden it
gives me this error message every so often:
The only way to fix it is to close the form and reopen it. I think
something changed while back, as it worked perfectly for a long time. I'm
running 2007 on Vista, but it was doing it before on 2002 on XP.
HERE IS MY CODE:
Private Sub SearchBy_AfterUpdate()
Me.SearchFor.RowSourceType = "Table/Query"
Me.SearchFor.RowSource = "SELECT DISTINCT [" & _
Me.SearchBy & "] FROM [" & _
Me.SearchBy.RowSource & _
"] ORDER BY [" & Me.SearchBy & "]"
End Sub
==========================================
Private Sub SearchFor_AfterUpdate()
On Error GoTo handler
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.Findfirst "[" & Me.[SearchBy] & "] = " & Chr(34) & Me![SearchFor] & Chr(34)
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Me.SearchFor = Null
handler:
If Err.Number = 3464 Then
rs.Findfirst "[" & Me.[SearchBy] & "] = " & Me![SearchFor]
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Me.SearchFor = Null
End If
End Sub
Thanks
Curtis