Login Code to Open BRANCHES FORM

  • Thread starter Thread starter Downie
  • Start date Start date
D

Downie

Login Code to Open BRANCHES FORM

Private Sub Command4_Click()
Dim SQLString As String
Dim cnn As New ADODB.Connection
Dim cmd As New ADODB.Command

Dim rst As New ADODB.Recordset


DoCmd.SetWarnings False

Set cnn = CurrentProject.Connection
Set cmd.ActiveConnection = cnn


SQLString = "SELECT * "
SQLString = SQLString & "FROM estimates "

cmd.CommandText = SQLString

rst.CursorLocation = adUseClient
rst.Open cmd, , adOpenKeyset, adLockOptimistic

If (rst!Login) = TB_Login And (rst!Password) = TB_Password
Then

**** Me.OpenArgsformBRANCHES

End If
DoCmd.SetWarnings True
End Sub
 
you don't say what the problem is or what you are trying to do, but this line:
Me.OpenArgsformBRANCHES
Is not correct. Please post more info.
 
oops...
yeah, I was hoping you could tell me the command instead of
"Me.OpenArgsformBRANCHES "that will open my Branches Form.

the user enters their Login and Password on the Login Form
Click the Login button on the Login Form

Runs the Login and Password against the records in the Estimates Data
Table.

If there is a match the BRANCHES Form is opened.
 
I saw your other post and answered the question regarding the syntax there.
Nothing in either post mentioned looking up the password and long in a table.
You can do that with a DLookup against your estimates table using the login
and Password:

If Not IsNull(DLookup("[Login]", "Estimates", "[Login] = '" & Me.Login & _
"' AND [Password] = '" & Me.Password & "'") Then
DoCmd.OpenForm "FormName"
Else
MsgBox "InCorrect Login"
End If

[Login] and [Password] are the fields in your table
Me.Login and Me.Password are the text boxes on your form
The code above assumes both are text fields in your table. If either are
numeric fields, you need to remove the single quotes around it.
 
Back
Top