Discussion Locked

DoCmd.OpenForm with WHERE criteria

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have a form where people can enter a userid and password to enter the system and then have the choice of entering or changing password. The form does a DLOOKUP on USERS table to check if the userid and password combination are legit. If they choose change password, I have the following code (I save the userid and group in global variables for other usage):

userloggedin = Me.UseridPrompt.Value
usergrouploggedin = DLookup("UserGroup", "Users", _
"[Userid]=""" & Me.UseridPrompt.Value & """")
DoCmd.Close acForm, "Volunteer Login Page", acSaveNo
stLinkCriteria = "[Userid] = '" & userloggedin & "'"
DoCmd.OpenForm "Volunteer Change Password", , , stLinkCriteria

The Change Password form has 3 fields on it - Userid which is bound to USERS and 2 unbound fields for new password. The Userid field is not Enabled as I don't want anybody typing there - I just want to display the Userid. When it opens the Change Password form, it does not display the contents of the Userid field but, rather leaves it blank. What do I have to do to get it to display the Userid field for the individual that logged in?

Thanks.

1 reply

by adiaz1

If you want to Displays the value of the Userid field in the Users table
Try this

usergrouploggedin = DLookup("Userid", "Users", _
"[Userid]='" & Me.UseridPrompt.Value & "'")

This discussion is closed to new replies.