Access 2007-2016
Access 2000-2003
Access Seminars
TechHelp Support
Tips & Tricks
Access Forum
Course Index
Topic Glossary
Insider Circle
Home   News   Tips   Glossary   Templates   Forums   Help   Logon   Order   Contact Us  
Courses - Microsoft Access 322
Description: Advanced Access Recordsets
Running Time: 81 minutes
Pre-Requisites: Access 321 very strongly recommended
Previous Lesson: Access 321
Next Lesson: Access 323
Main Topics: Record Locking, Seek, OpenDatabase, Fields Collection, Custom User Logon, Password, Security
Versions: This course is valid for Access 2000 through 2003. If you are using Access 2007 or 2010, you will still benefit from this course. You will find that the concepts are the same, but there are cosmetic differences between the versions.


Order before 4/22/2019 to get a FREE upgrade to our Access 2010 version!
Click here for details


We begin with covering some additional information on Recordset options, record locking, types, counts, and so on.

You will learn about the Seek method, which is similar to Find, but faster and more efficient, although it does have some limitations.


You'll learn about the CancelUpdate method. You'll learn how to use the OpenDatabase command to work with ANY database file, not necessarily just the currently open database.


You'll learn about the Fields collection, and how to loop through all of the fields in a recordset using the For Each method. You'll also learn how to determine the type of data that is stored in each field.


Next we'll have some fun by creating our own secure user logon for our database. I personally don't like Access' built in security, so I've built my own.


I'll also show you how to create your own LogIt function to track everything every user does in your database.


Access 322 - Course Outline

1. Recordset Tips, Part 1
Recordset Options
- dbAppendOnly
- dbDenyWrite
- dbDenyRead
Record Locking Options
- dbPessimistic
- dbOptimistic
RecordCount Not Working
- dbOpenTable: OK
- dbOpenDynaset SQL: OK
- dbOpenDynaset Table: NOT OK
- dbOpenSnapShot: NOT OK

2. Recordset Tips, Part 2
Seek Method
Must Be Indexed Field
Limitations of Seek
CancelUpdate Method

3. Opening a Different Database
OpenDatabase Method
Reading One Value From Multi-Select Box
OnDoubleClick - Which Is Selected?
Reading Records From A Different Database

4. Fields Collection
Displaying All Field Values
Showing Field Properties
Fields Collection
Type of Data
Using the FieldName as a Variable

5. Project: User Logon, Part 1
Why I Don't Like Access User Level Security
Create a User table
Create a Logon form
Password type Input Mask
Recordset to Check Password
Default Command Button

6. Project: User Logon, Part 2
Create a Log table
LogIt function
With, End With
Make LogIt a Global Sub in a Module
Global Variables
Global CurrentUserID, CurrentUsername
Cancel a Form OnOpen Event



Student Interaction: Microsoft Access 322

Richard on 1/1/2008:  Recordset options, seek, OpenDatabase, Fields collection, User Logon Form, create a Log table
 Harry Mullin on 3/5/2009: Suggestion: when needing to locate a file with an exact path where the file is in the SAME folder as the currentdb, use -
Set db = OpenDatabase(CurrentProject.Path & "\Orders.mdb")

 Harry Mullin on 3/5/2009: General Access question - the default indent spacing in code window does not match the tab setting. Hence, wizard created code will set its indents at a different place than hand typed code using the tab key or indent button.

How can the two be sync'd?

Richard Rost on 3/6/2009: Harry, in the VB EDITOR go to Tools > Options and on the Editor tab you'll see "Tab Width" which is where you can specify the size of your tabs (4 characters is the default).
 Harry Mullin on 3/6/2009: I have a form whose record source is a query and it is filtered by a Primary Key. I'm using an UPDATE SQL statement to add information to a field (can't do it directly as the query won't allow edits (Totals are on).

When I .requery the form, the filter goes away and other data appears. Is there a way around this?

Forms!ChitListF.Filter = "[EvDtID] = " & Forms!ChitListF.EvDtIDtxt
Forms!ChitListF.FilterOn = True

doesn't work.

 Harry Mullin on 3/6/2009: Forum question:
Is there a way to review all comments for a group of lessons (eg Advanced Recordsets) without worrying about which specific lesson one is in? I got your comments back on my questions, but now can't find them easily.

Richard Rost on 3/9/2009: Harry, instead of using a filter, change the RecordSource of the form with a dynamic SQL statement like I show in Access 311 (Dynamic SQL Form). Personally, I hate filter. They work for VERY basic criteria only.
Richard Rost on 3/9/2009: Harry, go to the page on my web site for that course. At the very bottom of the course description/outline you'll find ALL of the student comments (and my replies) for the entire course. For example, Access 322 is at You can also find it by clicking on the COURSES link on the main menu of the web site. Courses > Microsoft > Access > 322.
BRYAN binkerd on 5/26/2009: time of class 04:54, I am using Access 2003 front end with SQL Server Express 2005 Backend. I found the hard way that in order to access the SQL server backend through DSN(ODBC) connection that the OpenRecordset("CustomerT",dbOpenDynaset,dbseechanges) had to be in place due to an error message stating that I was accessing a sql server table with an identity column. (error 3622)
Thought maybe that bit might help.

Richard Rost on 5/27/2009: Bryan, thanks for the update. I don't have SQL Server 2005 Express here, so I would have never caught that.
Ray McCain on 10/1/2009: I am getting a "From" error in the following item:Set rs = db.OpenRecordset("SELECT * From UserT where Username='" & UserName & "' and Password='" & Password & "'")
Apparently the username is getting set to the username field but the password is not getting set to the password field.
What am I doing incorrectly?

Richard Rost on 10/2/2009: Ray, your SQL code looks fine. Check your field names and make sure they match your form fields exactly. This is usually caused by a misspelling of field name.
peter jansen on 2/23/2010: Dear Richard how can I use
a wildcard in the DAO seek method?I mean instead of choosing 5 I can choose any other value without changing it in the code.
Thanks.time index 2:38

Reply from Richard Rost:

Sure. I put in a "5" just as an example. You could substitute a variable or a form field there if you want to.

 david on 3/28/2010: in design view of the form. How can you read the full name of the control

Reply from Richard Rost:

You can always open up the properties for that individual control to see its NAME. Once you know that, then it's always:


David Richardson on 5/6/2010: My last question was partially answered. I do not recall which video I was watch, but you have hovered over the control and the full name appeared. How does the full name gets displayed by hoveering over the control?

Thank you for your help

Reply from Richard Rost:

David, look for the Control Tip Text property. Whatever you put in there will appear when you hover over the control.

Mubeezi Micah on 7/12/2010: Dear Richard,

At time index 9:12, you demonstrated how to "inprint" the current user name onto the main menu. I added something cool that i would like to share with you and my fellow students. That is, the Main Menu should greet the current user as "Good morning Richard!" depending on what (PC system) time they they log in. See below what i used for my database:
If Time >= #12:00:00 AM# And Time < #12:00:00 PM# Then
CurrentUserLabel.Caption = "Good Morning " & CurrentUserName & "!"

End If

If Time >= #12:00:00 PM# And Time < #5:00:00 PM# Then
CurrentUserLabel.Caption = "Good Afternoon " & CurrentUserName & "!"

End If

If Time >= #5:00:00 PM# And Time <= #11:59:00 PM# Then
CurrentUserLabel.Caption = "Good Evening " & CurrentUserName & "!"
End If

Doesn't it look cool? Probably the Select Case statement or Elseif would look cooler.

Thank you for the good work and keep it up!


Mubeezi Micah on 7/22/2010: Dear Richard,

You have been very quiet of late. I noticed you approved our comments. Thank you. However, some of the comments were questions and we were expecting some form of expert answer from you. Your replies are however not visible. Would you be kind and reset to VISIBLE or write the responses again?

Best regards,


Reply from Richard Rost:

Micah, sorry ive been absent lately. Im working on a big project that is taking all of my time. I have marked many of your questions to follow up on and I will answer them as soon as I can.

Kenya on 10/5/2010: Hi Richard, I have purchased a few of your lessons and I love them, you have saved my job on many occasion. THANKS...I have recently run into a problem with autoexec, the module is set up to allow the full Access menu's when certain users are logging in but the problem is when the auto exec crashed it locked everyone out of the database. We were unable to access any of the menus to check the code of the macro or to remove it. How can I prevent this from happening again or is there another way to block my database menus without running a macro?

Reply from Richard Rost:

Hold the SHIFT key down and restart your database. This will bypass your startup macro and let you get to the database window to figure out what's wrong.

Lilly Nguyen on 4/9/2011: Do you have any course that teach how to create Access for multi users?

Reply from Richard Rost:

I have talked about it briefly in several of my courses, but it's not that difficult. You just need to set up a SHARED FOLDER on your network that everyone has read/write access to. Then place your database there. However, keep in mind it's not really secure. I talk about this in great depth in my Access Security Seminar.

John Hubbard on 9/16/2018: Richard
Please help - clicking logon button brings Compile Error: variable not defined. Followed everything in video - I thought.
your help is greatly appreciated

John Hubbard on 9/16/2018: please disregard last question. sorry thanks

You may want to read these articles from the 599CD News:


Visual Basicindex
Account Login
Online Theater
Lost Password
Free Upgrades
Insider Circle
Student Databases
Change Email
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search Our Site
Waiting List
Production Schedule
Collapse Menus
Live Chat
Customer Support
WalkThru Tutorials
Consulting Services
About Us
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Video Tutorials
MYOLP Memberships
Idiot's Guide to Excel
Volume Discounts
Payment Info
Terms of Sale
Gift CDs
Live Chat
General Info
Support Policy
Contact Form
Email Us
Mailing Address
Phone Number
Fax Number
Course Survey
Facebook    Twitter

Google Plus    LinkedIn

Blog RSS Feed    YouTube Channel
Richard Rost Microsoft MVP