You have an "END IF" and "LOOP" out of order. It should be:
Code:
bFoundMatch = True
Exit Do
rstUserPwd.MoveNext
Loop
End If
You don't need to have ".Value" because the value property is the default property.
"Form_LoginScreen.cmdlogintext" is not the correct to reference a control on a form. If the code is in the form module, use "Me.ControlName" ie "Me.cmdlogintext"
Otherwise use "Forms!LoginScreen.cmdlogintext"
Why don't you open the query already filtered?
You could use something like"
Code:
Private Sub LoginBut_Click()
Dim dbs As Database
Dim rstUserPwd As Recordset
Dim bFoundMatch As Boolean
Dim sSQL As String
Set dbs = CurrentDb
sSQL = "Select cmdlogintext, cmdpasswordtxt FROM TableName WHERE cmdlogintext = '" & Me.cmdlogintext & "' AND cmdpasswordtxt = '" & Me.cmdpasswordtxt & "';"
Set rstUserPwd = dbs.OpenRecordset(sSQL)
If rstUserPwd.RecordCount > 0 Then
' Open the next form here and close this one
rstUserPwd.Close
Set rstUserPwd = Nothing
Set dbs = Nothing
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "Main"
Exit Sub
Else
'
MsgBox "Incorrect Username or Password"
End If
rstUserPwd.Close
Set rstUserPwd = Nothing
Set dbs = Nothing
End Sub