Code Error

hmongie

Registered User.
Local time
Today, 15:31
Joined
May 17, 2003
Messages
99
I can't get this working. The code was posted by someone else. Anybody that can help, thanks so much.
........................
I have a table name main1.
I have a form name main2. (input box and command button)

..........................I placed the code into my command button......

Private Sub Command2_Click()
Set con = Application.CurrentProject.Connection
Set rs = CreateObject("ADODB.Recordset")
stSql = "SELECT * FROM main1 "
'I have the password stored in this table!

rs.Open stSql, con, 1 ' 1 = adOpenKeyset

If Not (rs.EOF) Then
If rs![PASSWORD] = Form_main2.Text1.Value Then
'Text1 is my unbound box for the user to enter the password!
DoCmd.OpenForm "intro"
DoCmd.OpenForm "main2"
DoCmd.Close
Else
MsgBox "You have entered the wrong Password!"
End If
End If
End Sub
 
there is no error.

The form doesn't execute anything. the text box is not accessible at all.

What I was looking for was a way to create a user list with password, if the user inputs the correct password then a new form will open else, an alert appears.


thanks for any inputs..
 
try...

Code:
Private Sub Command2_Click()
   dim con as new adodb.connection
   dim rs as new adodb.recordset

   set con = Application.CurrentProject.Connection
   with rs
      .open "SELECT Password FROM main1 WHERE Password = '" & Me.Text1 & "'", con
      if not .eof then
         DoCmd.OpenForm "intro"
         DoCmd.Close, acform, me.name
      Else
         MsgBox "You have entered the wrong Password!"
      End If
      .close
   end with
   set rs = nothing
   set con = nothing

End Sub
 

Users who are viewing this thread

Back
Top Bottom