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 
Variable Query
Thomas Corbett 
     
4 years ago
Hi, I have a form with a user login and queries set up for various functions. Is it possible to have a query field/s updated to the username from the login?

Thanks

Tom -
Richard Rost  @Reply  
           
4 years ago
Sure. How are you storing the username? Global variable? TempVars? Form Field? Just use that in your query.

I show how to do this in my Access Security Seminar.
Thomas Corbett OP  @Reply  
     
4 years ago
Currently only in the user table
Kevin Yip  @Reply  
     
4 years ago
Sounds like you need a "parameter query."  Richard has a free video on the basics of it.  My picture shows what a parameter looks like in design view.  You run it, and it prompts you to *manually* enter a value for the parameter; in this case,the value will be used as the criteria.  In my example, the parameter is called [country name contains], which must be a unique name enclosed in square brackets.  "Unique name" means it is not used anywhere else inside this particular query.

The above method only accepts a manual entry.  To pass something from a table, you need VBA.  First you need to look up the value with, say, DLookup().  Then you pass that value to the query's parameter with my sample VBA code below.  (I don't know if Richard has a video using parameter queries in VBA or not.)  The syntax is fairly simple, but you need to be proficient in using Recordset and QueryDef in VBA.  And note that NO square brackets are used for the parameter name here (i.e. "country name contains").  This code will yield a Recordset "r" that contains the result of the query.
Kevin Yip  @Reply  
     
4 years ago

Thomas Corbett OP  @Reply  
     
4 years ago
Thank you Kevin, I will try this :)
Thomas Corbett OP  @Reply  
     
4 years ago
Thank you I'll try that :)

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: 4/30/2026 11:41:06 AM. PLT: 1s