A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

How set focus to sub form?



 
 
Thread Tools Display Modes
  #1  
Old September 13th, 2005, 10:46 PM
mscertified
external usenet poster
 
Posts: n/a
Default How set focus to sub form?

I have a form and a subform with a one-many relationship. Before I exit the
form, I must validate that there is at least one row in the subform.
Is there an easy way to do this?
Also, if there is no row, I display a msgbox and then need to set focus to
the subform, how? I tried the syntax in my Access book and it does not work.
Here is what I used:

Me.Controls("frmCorrespRuleXref_subform").Form.Con trols("Chapter").SetFocus
  #2  
Old September 13th, 2005, 10:46 PM
Ofer
external usenet poster
 
Posts: n/a
Default

On the unload event of the form write the code
' To check if any records were entered
If Me.SubFormName.Form.RecordsetClone.RecordCount = 0 then
cancel=true ' Wont let exit the form
me.SubFormName.Form.FieldName.SetFocus ' Set the focus to the field
exit sub
End if

--
I hope that helped
Good luck


"mscertified" wrote:

I have a form and a subform with a one-many relationship. Before I exit the
form, I must validate that there is at least one row in the subform.
Is there an easy way to do this?
Also, if there is no row, I display a msgbox and then need to set focus to
the subform, how? I tried the syntax in my Access book and it does not work.
Here is what I used:

Me.Controls("frmCorrespRuleXref_subform").Form.Con trols("Chapter").SetFocus

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo Box NotInList - How To Add Data To Underlying Table 10SNUT Using Forms 19 July 8th, 2005 09:12 PM
Moving focus from sub form to main form Robin Chapple Using Forms 2 June 11th, 2005 09:50 AM
Is it possible to show both "Yes" and "No" answers from a "yes/no" checkbox? Colin Foster New Users 28 March 18th, 2005 02:19 PM
printing label for record that has focus on the form babs Setting Up & Running Reports 0 February 4th, 2005 06:01 PM
auto entry into second table after update Tony New Users 13 July 9th, 2004 10:42 PM


All times are GMT +1. The time now is 01:12 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.