When you're referencing a Recordset field, you need to use a different format than you do in a straight SQL Query.
Code:
Dim rst as DAO.Recordset ' Created a VBA Object to hold your Query Results
Set rst = CurrentDb().OpenRecordset("<Include SQL Query Here>", dbOpenSnapshot) ' Runs your SQL Query and loads the results in to your VBA Object
At this point, things differ depending on how many Records your Query can return. . .
If you're sure the Query will only return a single Record, then you can use the following code to check against it:
Code:
If StrComp(rst("<Insert Field Name Here>"), Me!txtPassword, 0) = 0 Then
' Do your stuff
Else
' Do your stuff
End If
If there could be multiple Records in the Query results, then you'll need to search for the one you want first
Code:
Dim strCriteria as String ' the String that'll hold our search criteria
strCriteria = "[<Insert Field Name Here>]='" & <WhatYou'reLookingFor> & "'"
rst.FindFirst strCriteria ' Find the first Record that matches your search. If the search doesn't find anything, then rst.NoMatch will equal True
'Always check for rst.NoMatch!
If rst.NoMatch = True Then
' No matching Record was found!
Else
' We found a matching Record, do your StrComp() check!
If StrComp(rst("<Insert Field Name Here>"), Me!txtPassword, 0) = 0 Then
' Do your stuff
Else
' Do your stuff
End If
End If