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

DLookup Next Record

Status
Not open for further replies.

JOD59

Technical User
Dec 17, 2003
39
US
I have a password table with the fields
PasswordID AutoNum
InsId Text
Name Text

I'm using this code to password protect a field

Private Sub Detail_Click()
Dim strpword As String
Dim iResponse As Integer


strpword = InputBox("Enter password")
If strpword = DLookup("[Password]![InsId]", "[Password]") Then
Me.cboDate.Enabled = True
Exit Sub
Else
iResponse = MsgBox("Not Authorizes for Updates!", vbOK)
End If

End Sub


The code works fine for the first record but does not find records after the first. I'm new to VB but I believe I need a criteria or a loop. Can some one please help. Thanks
 
Replace this:
If strpword = DLookup("[Password]![InsId]", "[Password]") Then
By this:
If strpword = DLookup("InsId", "Password", "InsId='" & strpword & "'") Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top