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!

setfocus

Status
Not open for further replies.

pbrown2

Technical User
Jun 23, 2003
322
0
0
US
After a user updates a field I need to have the focus to set to a subform that is in the main form. Basically, after the update the check box, they need to go to the subform to complete the data entry. I was going to place this code in each of the check boxes After update event
I tried
Paint subform.setfocus

However it says it can not find the vairable not defined.

Would like to avoid tab set because they have a choice of check boxes and would like to make it "brainless" so the user does not need to keep tabing or have to manually click on the field in the subform

Thank you for any and all help,

PBrown
 
Not sure where the "Paint" comes from. Is this the name of a subform. To set focus to a subform, try:
Me.subformcontrol.SetFocus

Duane
MS Access MVP
 
Me.paint subform.setfocus gave me the same error.

Perhaps this will help explain more:

There are two forms:
Paint & Paint subform

After the user clicks on the check box I need the focus to be set to the subform (field = Description)so they can continue entering data.

Thank you for any and all help,

PBrown
 
Sorry, I didn't anticipate a space in your subform control name. Spaces in object names are evil. Try:
Me.[paint subform].setfocus
If you need to set the focus to a specific control in the subform, you may need to code another line:
Me.[paint subform].setfocus
Me.[paint subform].Form.txtMyControl.SetFocus


Duane
MS Access MVP
 
it says it can not find the fild "paint subform" Error # 2465

Thank you for any and all help,

PBrown
 
Alright perhaps someone can take a look at the code(s) that I have tried that do not work and see something that has been overlooked, again all help is appreicated.

Using A97:
Main form: Paint
Sub form: Paint subform


Feild on Main form: System 1
Needs to have After Update go to subform so that the user
can enter more data
Tried:
Me![paint subform].setfocus (error = can not find
field, "paint subform")
Me![description].form![paint subform].setfocus (error =
can not find field "description")
Me![paint subform].form.[description].setfocus (error =
can not find field "paint subform")
Me![description].form.[paint subform].setfocus (error =
can not find field "description")

Since the user has a choice of system 1, 2 or 3 I was
planning to enter the code at the after update for each.
I was attempting to stay away from tab set to "make it
easier for the end user"


Thank you for any and all help,

PBrown
 
Do you have a control on your form named "Paint subform" or is the control named something else?

Duane
MS Access MVP
 
That is what it was.... the control name has a ' at the begininging. once I retyped the control name your original idea worked.

Thank you for your help!


That is one thing that I will check first off if anything else goes astray!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top