I created a login form that opens a main form.
FRMLOGIN form is created from a tbl_Sales_Reps table.
Fields in table are:
Rep# (number), Rep_Name (text), Password (text).
Fields in FRMLOGIN are:
Combo0: SELECT tbl_Sales_Reps.[Rep#], tbl_Sales_Reps.Rep_Name FROM tbl_Sales_Reps - rep selects his/her name from combo box.
Text4, Unbound - rep enters his/her password
Command6: This is the Click button that is suppossed to open the FRM_QRYCUSTOMERS_and_SALESREP_INFO form.
The problem is that this works for user Admin but does not work for the reps. I'm guessing I'm doing something wrong with tbl_Sales_Reps info in the code.
Here's the code and THANKS A LOT FOR YOUR HELP!!
Private Sub Command6_Click()
On Error GoTo Err_Command6_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim conDB As ADODB.Connection
Dim rsTbl_Sales_Reps As ADODB.Recordset
Dim strPassword As String
Set conDB = New ADODB.Connection
conDB.Provider = "Microsoft.Jet.OLEDB.4.0"
conDB.Open "\\Backup\Departments\Mrkt\Telemarketing_Database\1 .mdb", "Admin", ""
Set rsTbl_Sales_Reps = New ADODB.Recordset
rsTbl_Sales_Reps.Open "select Password from Tbl_Sales_Reps where [Rep#]=" & Me![Combo0], conDB
strPassword = Trim(rsTbl_Sales_Reps!Password & "")
rsTbl_Sales_Reps.Close
Set rsTbl_Sales_Reps = Nothing
conDB.Close
Set conDB = Nothing
Text4.SetFocus
If strPassword = Trim(Text4.Value & "") Then
stDocName = "FRM_QRYCUSTOMERS_and_SALESREP_INFO"
If Me![Combo0] <> 9 Then '9 = Admin
stLinkCriteria = "[Rep_Name]=" & Me![Combo0]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
DoCmd.OpenForm stDocName
End If
'Form_FRM_QRYCUSTOMERS_and_SALESREP_INFO.gstrRep_Name = Me![Combo0]
Else
MsgBox "Wrong Password"
End If
Exit_Command6_Click:
Exit Sub
Err_Command6_Click:
MsgBox Err.Description
Resume Exit_Command6_Click
End Sub
FRMLOGIN form is created from a tbl_Sales_Reps table.
Fields in table are:
Rep# (number), Rep_Name (text), Password (text).
Fields in FRMLOGIN are:
Combo0: SELECT tbl_Sales_Reps.[Rep#], tbl_Sales_Reps.Rep_Name FROM tbl_Sales_Reps - rep selects his/her name from combo box.
Text4, Unbound - rep enters his/her password
Command6: This is the Click button that is suppossed to open the FRM_QRYCUSTOMERS_and_SALESREP_INFO form.
The problem is that this works for user Admin but does not work for the reps. I'm guessing I'm doing something wrong with tbl_Sales_Reps info in the code.
Here's the code and THANKS A LOT FOR YOUR HELP!!
Private Sub Command6_Click()
On Error GoTo Err_Command6_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim conDB As ADODB.Connection
Dim rsTbl_Sales_Reps As ADODB.Recordset
Dim strPassword As String
Set conDB = New ADODB.Connection
conDB.Provider = "Microsoft.Jet.OLEDB.4.0"
conDB.Open "\\Backup\Departments\Mrkt\Telemarketing_Database\1 .mdb", "Admin", ""
Set rsTbl_Sales_Reps = New ADODB.Recordset
rsTbl_Sales_Reps.Open "select Password from Tbl_Sales_Reps where [Rep#]=" & Me![Combo0], conDB
strPassword = Trim(rsTbl_Sales_Reps!Password & "")
rsTbl_Sales_Reps.Close
Set rsTbl_Sales_Reps = Nothing
conDB.Close
Set conDB = Nothing
Text4.SetFocus
If strPassword = Trim(Text4.Value & "") Then
stDocName = "FRM_QRYCUSTOMERS_and_SALESREP_INFO"
If Me![Combo0] <> 9 Then '9 = Admin
stLinkCriteria = "[Rep_Name]=" & Me![Combo0]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
DoCmd.OpenForm stDocName
End If
'Form_FRM_QRYCUSTOMERS_and_SALESREP_INFO.gstrRep_Name = Me![Combo0]
Else
MsgBox "Wrong Password"
End If
Exit_Command6_Click:
Exit Sub
Err_Command6_Click:
MsgBox Err.Description
Resume Exit_Command6_Click
End Sub