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 
SetFocus
Masih Ostad Novin 
     
2 years ago
Hi.
I have a form for registration and some fields are mandatory. I wrote a validation code and it works but when the user leave the field blank and the msg box pops up I want that setfocus remains in that blank field and not jump to next field. How can I do that? See images!
Thanks.
Masih
Masih Ostad Novin OP  @Reply  
     
2 years ago

Masih Ostad Novin OP  @Reply  
     
2 years ago

Masih Ostad Novin OP  @Reply  
     
2 years ago
MemberUsername = Username field
Kevin Robertson  @Reply  
          
2 years ago
I would put the code in the Click event for the Button before processing the entered data.

If IsNull(MemberUsername) or MemberUsername = "" Then
    MsgBox "Username must not be left blank."
    MemberUsername.SetFocus
    Exit Sub
End If
Masih Ostad Novin OP  @Reply  
     
2 years ago
Thanks Kevin, that's great. Working but it doesn't wotk on the combo boxes: Region and Hospital. These are cascading combo boxes. Any idea??? Thanks!
Masih Ostad Novin OP  @Reply  
     
2 years ago

Kevin Robertson  @Reply  
          
2 years ago
The Default Value in the table is probably zero (0) so check for that instead of the empty string.
Alex Hedley  @Reply  
           
2 years ago
You can also .Dropdown if you want them to open ready to pick a value.
Masih Ostad Novin OP  @Reply  
     
2 years ago
Thanks Kevin, it works and I also applied .dropdown, thanks to Alex. I have seen the videos about the save button and autosave. But I want the user to be able to "not save" and exit the form. For example if the user fills in the username and password but not the rest. I don't want username and password saves to the table. How can I do that? Thanks.

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/7/2026 4:53:48 AM. PLT: 1s