I am creating a log-in form for a database and am running into a 'Too few parameters' error when trying to login. I am using the login form to determine which form should be opened (based on a user's department) and to use the login ID as a parameter in a query. Here is the code I am using on the login form that is producing the error:
Private Sub txtLoginID_Exit(Cancel As Integer)
On Error GoTo Err_txtLoginID_Exit
Dim dbs As Database, rst As Recordset
Dim SQL As String
Dim strLoginID As String
txtLoginID.SetFocus
SQL = "SELECT tblRep.Dept FROM tblRep WHERE tblRep.RACFID= txtLoginID.Text"
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(SQL, dbOpenDynaset)
If rst.RecordCount > 0 Then
gblLoginID = txtLoginID.Text
Select Case rst("Dept")
Case "Inbound"
DoCmd.Close
DoCmd.OpenForm "frmPipeline"
Case "CoBrand"
DoCmd.Close
DoCmd.OpenForm "frmPipeline"
Case "Outbound"
DoCmd.Close
DoCmd.OpenForm "frmPipeline"
Case "Retention"
DoCmd.Close
DoCmd.OpenForm "frmPipleine"
Case "Manager"
DoCmd.Close
DoCmd.OpenForm "frmPipeline"
Case "Fulfillment"
DoCmd.Close
DoCmd.OpenForm "frmFulfillment"
End Select
Else
MsgBox "Please re-enter your RACF ID"
End If
rst.Close
Set dbs = Nothing
Exit_txtLoginID_Exit:
Exit Sub
Err_txtLoginID_Exit:
MsgBox Err.Description
Resume Exit_txtLoginID_Exit
End Sub
Any suggestions? Thanks in advance!
Private Sub txtLoginID_Exit(Cancel As Integer)
On Error GoTo Err_txtLoginID_Exit
Dim dbs As Database, rst As Recordset
Dim SQL As String
Dim strLoginID As String
txtLoginID.SetFocus
SQL = "SELECT tblRep.Dept FROM tblRep WHERE tblRep.RACFID= txtLoginID.Text"
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(SQL, dbOpenDynaset)
If rst.RecordCount > 0 Then
gblLoginID = txtLoginID.Text
Select Case rst("Dept")
Case "Inbound"
DoCmd.Close
DoCmd.OpenForm "frmPipeline"
Case "CoBrand"
DoCmd.Close
DoCmd.OpenForm "frmPipeline"
Case "Outbound"
DoCmd.Close
DoCmd.OpenForm "frmPipeline"
Case "Retention"
DoCmd.Close
DoCmd.OpenForm "frmPipleine"
Case "Manager"
DoCmd.Close
DoCmd.OpenForm "frmPipeline"
Case "Fulfillment"
DoCmd.Close
DoCmd.OpenForm "frmFulfillment"
End Select
Else
MsgBox "Please re-enter your RACF ID"
End If
rst.Close
Set dbs = Nothing
Exit_txtLoginID_Exit:
Exit Sub
Err_txtLoginID_Exit:
MsgBox Err.Description
Resume Exit_txtLoginID_Exit
End Sub
Any suggestions? Thanks in advance!