2008-05-22, 22:36 #1
- Join Date
- Jan 2002
- Brugge, Belgium
- Thanked 0 Times in 0 Posts
Changing the focus from the main form to the subfo (Ms Access 2007)
In the book MS Access 2000 VBA, translated into the dutch language i read:
"When a form own a subform, and the focus is moved from the main form to the subform", that's equal to saving the data into the main form. On the same time the validationrule of the table that makes part of the recordsource of the form is checked.
Now to check this behavior if set for the field "ClientID" of a table "tblClients", that makes part of the recordsource of my mainform frmOrders as validationrule: "Is not Null" and a apropriate text as validationtext.
Now I open my form frmOrders. On this moment I see only the commandbuttons of frmOrders. When i click on the commandbutton "CmdNew", the whole frmOrders becomes visible as wel as the subform and is set ready to receive new data for a new order. If now by accicent I click in the first field of my subform without first entering a clientnumber in the field "Client_ID" in the mainform,no message becomes visible to let me know that i first of all have to enter a ClienID number, because this may not be null. Why doesn't this happens
In how far is it wright what is mentioned in the book about checking the validationrule of the table when moving the focus from the mainform to the subform?
Subscribe to our Windows Secrets Newsletter - It's Free!
Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!
+ Get this BONUS — free!
Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!
2008-05-22, 22:54 #2
- Join Date
- Mar 2002
- Thanked 16 Times in 16 Posts
Re: Changing the focus from the main form to the subfo (Ms Access 2007)
If you haven't entered anything in the main form, there is no record yet. So when you move to the subform, there is nothing to save, and hence the validation rule isn't checked.
If you enter something in any of the fields on the main form, then move to the subform, you should see the validation message if ClientID is still blank.