Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

set focus to control on sub form

Status
Not open for further replies.

mbair

Programmer
Aug 13, 2003
22
US
I have a textbox on a subform. After I run the afterupdate
event on the textbox I want to set focus to that same textbox if the textbox is null.
 
Hi mbair!
If you want to force the user to enter a value in the textbox (if it is bound) set its required property to Yes in the table design and the user will not be allowed to leave the form without completing it.

Also, use code like this in the [!]BeforeUpdate[/!] event of the control to disallow the null and force data entry:
Code:
[COLOR=blue]Private Sub[/color] myTextbox_BeforeUpdate()
     [COLOR=blue]If[/color] IsNull(Me.myTextbox.Value) = [COLOR=blue]True Then[/color]
          Cancel = [COLOR=blue]True
     End If
End Sub[/color]

Born once die twice; born twice die once.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top