Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Set rstLogin crash
David Wiedenfeld 

10 years ago
I have Windows 10 and Access 2016. I'm trying to get a database to run that works just fine on 64-bit Win7 and Access 2013. It's a split database, with the back end on MSSQL Server and the front end, of course, Access.

It seems that when ever this code runs it crashes Access 2016:

Private Sub Form_Open (Cancel As Integer)

Dim rstLogin As DAO.Recordset
DoCmd.Close acForm, "Login"

Set rstLogin = CurrentDb.OpenRecordset ("SELECT Role FROM Security WHERE User_Name = '" & strUserName & "';", dbOpenDynaset, dbSeeChanges)

If rstLogin.Fields ("Role").Value = "Admin"
Then
Else
  Me.cmdManageUsers.Visible = False
End If

End IF

End Sub

What this does is make a command button visible on the form if the user is designated as and administrator.

The bug seems to be in the "Set rstLogin" line.

What has Microsoft changed that would cause Access to crash on this?

If I avoid opening this form, everything else in the database seems to work


Reply from Alex Hedley:

Did you change or add any References in Access vba window.
Access can be funny depending on whether DAO is before or after ADO.

One suggestion is I'd always have the Visibility of the admin buttons as hidden and only enable when the function has checked otherwise it may never get hidden if it fails and give users access they shouldn't have.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/16/2026 8:17:42 PM. PLT: 1s