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

set focus from subform to control on form

Status
Not open for further replies.

DBritter

Technical User
Jun 28, 2000
37
US

I am having trouble setting the focus from a subform back to the main form. I need some type of code that I can reference.
I have no clue how to reference back to the form. I have tried using the gotocontrol function but it returns the current value in the control that I want to reference with a message of not having a field named that in the database.
I just need help.
Thanks
 
Not clear what event on the subform is going to trigger this, but any way, from the subform you can reference a control on the main form like so...

Forms![MainFormName]![ControlName].SetFocus

Hope this helps...

B-) ljprodev@yahoo.com
ProDev
MS Access Applications
 
this is how I referenced the control in the main form from the subform after the last control on the subform loses its focus.
Forms!frmChangeContactInformation!strDollarVolume.SetFocus

I in turn get an error of:"Object doesn't support this property or method"
what does that mean? strDollarVolume is a control like everything else right?
 
What type of control are you trying to set the focus to?
Is it a locked control?

B-) ljprodev@yahoo.com
ProDev
MS Access Applications
 
ok I have switched the focus to a yes no box and it works.
The strDollarVolume is a listbox. I Don't understand the difference in refering to one control versus the other. I guess that that is now my question. And is there a particular way to refer to list boxes that is different than other controls?
 
You should be able to set the focus a listbox like any other control. The main reasons that a control cannot receive the focus is...

1. It's Visible property is set to Yes
2. It's Enabled property is set to No
3. It's Locked property is set to Yes

Other than that I'm not sure what your problem is.

B-) ljprodev@yahoo.com
ProDev
MS Access Applications
 
The name of your control starting with str sounds more like a variable name than a control name. Are you sure that is the name of the control - is it not something like TxtControlName? You must reference the control. not the value in it.
 
in the properties menu it lists strDollarVolume as the control source. everything is visble enabled and unlocked. I don't know why it won't reference.
 
In the properties window where you saw the control source go to the tab labled "Other" and see what the actual name of the list box is.

B-) ljprodev@yahoo.com
ProDev
MS Access Applications
 
then what is the "name" field in the "All" tab.
 
It is the same. The "All" tab is a collection of the properties in all the tabs. ljprodev@yahoo.com
ProDev
MS Access Applications
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top