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

form-suborm

Status
Not open for further replies.

gray78

Programmer
Feb 3, 2005
78
US
I have a form(serial#) and a sub form(serial#sub). The sub form resides within the form. When I open the form, I want the cursor to be on the first field(tagno), which is a combo box. After choosing the tag # from the combo box, I want the cursor to move to the description field on the sub form. Currently when I open the form, the cursor goes directly to the description field. I would also like the cursor to move from the last field in the tab order on the sub form to the tagno field on the serial# form(main form)

Ok, thats all :)

Thanks
 
Check the actual TabIndex in the main form and have a look at the SetFocus method (hint: to move the cursor from the mainform to a control in the sub form you need to call SetFocus twice).

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Gray,
-Put this on your OnOpen event of your form:

Private Sub Form_Open(Cancel As Integer)
Me.Tagno.SetFocus

End Sub

------------------------------------------------------
-Put this on the Afterupdate event of your combobox:

Private Tagno_AfterUpdate()

Me.Serial#sub.Form![Description].SetFocus


Forms![Serial#]![Serial#sub].SetFocus
Forms![Serial#]![Serial#sub].Form![Description].SetFocus


End Sub

----------------------------------------------------------
-Put this on the AfterUpdate of Description field:

Private Sub Description_AfterUpdate()

Forms!Serial#!Tagno.SetFocus

End Sub
 
Correction:

-Put this on the Afterupdate event of your combobox:

Private Tagno_AfterUpdate()

Forms![Serial#]![Serial#sub].SetFocus
Forms![Serial#]![Serial#sub].Form![Description].SetFocus


End Sub
 
code is not working, getting a debug error
 
What kind of begug error?
Where are you having the debug? Which part of the code?

Paste your code and lets have a look....

Code assumes:
-Your main form called "Serial#"
The combobox is named "Tagno"

Your subform is named "Serial#sub"
The description field is named "Description"




 
Correct, the debugger is taking me to:
Forms![Serial#]![Serial#sub].SetFocus
 
So your having a debug error on the AfterUpdate event of your combox "Tagno"

Forms![Serial#]![Serial#sub].SetFocus
Forms![Serial#]![Serial#].Form![Description].SetFocus

Go to design view of your form. Right-click on your subform and go to properties, go to Other and make your subform is correctly named:

Name....... Serial#sub

 
still not working, checked and the sub form name was correct Serial#sub

What next?

Thanks
 
ok, it is working! Now, once i am in the last field(custid) of the sub form(serial#sub)and enter enter data or click "tab", i want to be able to go to the first field in the main for (serial#) as if I were opening the form fresh.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top