Reverse search in access

icusawme

New Member
Joined
Apr 26, 2003
Messages
7
:D The find button created by the wizard on a form will find the first entry matching search criteria, (first to last searching). I need to search for the LAST enty matching search criteria (last to first searching). Help!!
Thanks in advance for your help!
Wade
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Re: [b]Reverse [/b]search in access

In the "Search" criteria, you should be able to specify to search "All", "Up", or "Down". Searching up will find your last record, down will find your next record.
 
Upvote 0
Put this at the top where declarations go
Public gvar as Variant
-----------------
Put this behind the button you want to use.
Public Sub Find_Last()
On Error GoTo Err_find_Click

'StartTestCode
Dim dbs As Database, rst As Recordset, MyResponse As Variant, Response As Integer
Dim strCriteria As Variant
Screen.PreviousControl.SetFocus
strCriteria = InputBox("Enter Search Criteria", "FIND", gvar)
If strCriteria = -1 Then
MyResponse = strCriteria

GoTo Exit_find_Click
Else
DoCmd.FindRecord strCriteria, acAnywhere, , acUp, , , False
gvar = strCriteria
'If strCriteria.match Then
End If

'DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Exit_find_Click:
Exit Sub

Err_find_Click:
'MsgBox Err.Description
gvar = strCriteria
If Not strCriteria = Empty Then
MsgBox "(" & strCriteria & ") Not Found", , "RESULT"
Else

Response = acDataErrContinue
End If
Resume Exit_find_Click
'End Test Code

End Sub
 
Upvote 0

Forum statistics

Threads
1,221,540
Messages
6,160,417
Members
451,644
Latest member
hglymph

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top