I have a database with 3 tables. One table is named users, one is named auth, and the other is named password. I am trying to build a login form with 3 fields, User name, Auth, and Password. I want to type the info in each field. The hope is not to be forced to use a combo box. Just about any sample code that I have found downloads with an mdb extension. I am using access 2010 with database extension accdb. Any help in finding code for a login form or suggestions will be very much appreciated. As you can tell I am just learning access
For starters, why do you have 3 tables? It sounds like you'd want a single "Users" table, which would include fields for the user's password and auth (which I assume is some sort of authorization level). In any case, the same code you've found in MDB samples should also work in ACCDB format.
I misspoke regarding the tables. I have 1 table with 3 categories. The following code is from an mdb format file. It works in the original mdb format file but not in the accdb format. The little menu has 2 unbound fields and I am using a control to implement the code?????
Option Compare Database
Private Sub CancelButton_Click()
'Private Sub CancelButton_Click()
Private Sub okButton_Click()
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
If IsNull(Me.UserTxt) Then
MsgBox "Please enter a valid user name.", vbExclamation, "Error"
ElseIf IsNull(Me.PassTxt) Then
MsgBox "Please enter a valid password.", vbExclamation, "Error"
rs.Open "SELECT * FROM tblUser WHERE(UserName = """ & Me.UserTxt & """ AND Pass = """ & Me.PassTxt & """)", _
CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If rs.EOF Then
MsgBox "Invalid user name or password. Please try again.", vbExclamation, "Error"
MsgBox "Login Successful.", vbInformation, "Confirm!"
2007 has some security features. Is any code running at all? If not, make sure the database is in a Trusted Location (Office Button/Access Options/Trust Center/Trust Center Settings) or that you've explicitly enabled code (option on the menu bar).