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

How to determine number of records applied by filter

Status
Not open for further replies.

dkape

MIS
Mar 22, 2001
17
0
0
US
I have a form which when opened applies the following filter.

DoCmd.ApplyFilter , "USER_ID =" & "'" & Me![UserName] & "'" & " AND " & "USER_PASSWORD = [Enter Current Password]"


Me![UserName] is supplied by a module and [Enter Current Password] is a user prompt opened when opening the form.

The goal of this filter is to return on the record for the Me![UserName] when the proper password is entered in the prompt.

This works as desired when the proper password is entered but It not doing what I want when the wrong password is entered. I hope that if I can "grab" the number of records that the filter yields I can then evaluate that number for further processing.

For example:

if NumberOfRows < 1
MsgBox "Incorrect password, please try again"
DoCmd.Close acForm, "Frm_Main"
endif

So can anyone tell me how to get this value into something I can evaluate against?

thanks you
 
You can try...

dim db as Database
dim rst as recordset
dim intRecCnt as integer
set db = currentdb
'ApplyFilter
docmd.movelast 'You may not need these 2 lines
docmd.movefirst 'but I added them just incase.
intRecCnt = rst.Count



AccessGuruCarl
Programmers helping programmers
you can't find a better site.
 
How are ya dkape . . .

Perhaps this:
Code:
[blue]   If Not Me.Recordset.RecordCount Then
      MsgBox "Incorrect password, please try again"
      DoCmd.Close acForm, "Frm_Main"
   End If[/blue]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top