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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

change focus if a field is blank in a subform to another subform 1

Status
Not open for further replies.

wz

Programmer
Feb 16, 2001
88
US
I want the end user to hit enter in a text box and if it is left blank then I want the cursor to move to another text box.

I have a subform with a continuious view so that the user can enter as many fields (3 in each record) as needed then I want the end user to enter into the next field in record and if the first field is blank then I want the end user to enter into another subform. I tried this:

event procedure on Lost Focus:
If Me![fieldname] = 0 then
Forms![formname]![subformname].setfocus

it works - but I want to change the "0" to be a blank field. I couldn't get isnull to work.

any ideas?
 
How are ya wz . . .

I don't know how the subForms are synchronized or wether there on the same subForm level. Considering there on the same level (lvl1), in the [blue]GotFocus[/blue] event of the trigger textbox, copy/paste the following:
Code:
[blue]   Dim sfrm2 As Control

   Set sfrm2=Forms![purple][B][I]MainFormName[/I][/B][/purple]![purple][B][I]sfrm2Name[/I][/B][/purple]

   If Trim(Me![[purple][B][I]1stFieldName[/I][/B][/purple]] & "") = "" then
      sfrm2.SetFocus
      sfrm2.Form![purple][B][I]sfrm2TextboxName[/I][/B][/purple].SetFocus
   End If

   set sfrm2 = Nothing[/blue]

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Thank you! Thank you!

I was starting to pull my hair out :) wz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top