im trying to make a log in form, and i keep getting "Run-time error '3075': Syntax error (missing operator) in query expression 'UCase(trim(User Name))='". i have made a table called UNP. it has two fields: User Name and Password. Im using Access 2007. here is my code
The code works up until
Set tempRecordSet = CurrentDb.OpenRecordset("select * from UNP where UCase(trim(User Name)) = '" & UCase(Trim(txtUser)) & "'")
Can anyone help?
The second question i have is when i view my logon form in form view, and i select my user name from a drop down list, it inserts my password in the password box by itself. how do i stop this?
Thanks,
Valgore
Code:
Private Sub Command12_Click()
'check for null User
If IsNull(Trim(txtUser)) Then
MsgBox "User Name required.", vbExclamation
txtUser.SetFocus
Exit Sub
End If
'check for null password
If IsNull(Trim(txtPassword)) Then
MsgBox "Password required.", vbExclamation
txtPassword.SetFocus
Exit Sub
End If
Dim tempRecordSet As Recordset, Password As String
Set tempRecordSet = CurrentDb.OpenRecordset("select * from UNP where UCase(trim(User Name)) = '" & UCase(Trim(txtUser)) & "'")
If tempRecordSet.RecordCount <> 0 Then
Password = UCase(Trim(tempRecordSet("UNP.Password")))
End If
tempRecordSet.Close
Set tempRecordSet = Nothing
If Password <> UCase(Trim(txtPassword)) Then
MsgBox "Access Denied", vbExclamation
Else
MsgBox "Access Granted", vbExclamation
End If
txtPassword = Empty
End Sub
The code works up until
Set tempRecordSet = CurrentDb.OpenRecordset("select * from UNP where UCase(trim(User Name)) = '" & UCase(Trim(txtUser)) & "'")
Can anyone help?
The second question i have is when i view my logon form in form view, and i select my user name from a drop down list, it inserts my password in the password box by itself. how do i stop this?
Thanks,
Valgore