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!

change the "Row source" of a combo box

Status
Not open for further replies.

bnath001

Programmer
Aug 18, 2000
100
US
HI,

In the detail section of my form, and I have a subform in that detail section. I have a combo box in the subform and I would like to change the control source/row source properties dynamically.

How can I access those properties of the combo box which is in the subform.

could someone give some suggestion?

thanks
bvyas
 
In whichever event you have chosen to change the RowSource, use this syntax (assuming this is being done from your MAIN form)

Forms![YourMainForm]![YourSubFormName!Form].SetFocus
Forms![YourMainForm]![YourSubFormName!Form].[YourComboBox].RowSource = "YourSQLString"

Have a look at the Access Helpfile topic Call Procedures in a Subform or Subreport for an explanation of this syntax.

HTH

Lightning
 
thanks. But it doesn't work.

frmTabCustomers is the Main form.
subItems is the name of the sub form.
cboNames is the combo box which is on the sub form (subItems)

Forms![frmTabCustomers]![subItems!Form].SetFocus
Forms![frmTabCustomers]![subItems!Form].[cboNames].RowSource = "tbl_Screens"

It says "Microsoft access doesn't find the field 'subItems!Form' referred to in your expression.

can you suggest if I am doing any mistake?

thank you
 
Oops! Sorry, my typing fingers aren't awake yet!!
Close the brackets after your Subform Name:

Forms![frmTabCustomers]![subItems].Form.SetFocus
Forms![frmTabCustomers]![subItems].Form.[cboNames].RowSource = "tbl_Screens"


"Sorry about that, Chief!"

Lightning
 
Lightning,
I appreciate for taking time in responding my question. But it still says "There is an invalid method in an expression"
when it runs
Forms![frmTabCustomers]![subItems].Form.SetFocus statement.

May be I should let you know exactly what I am trying to do.
1. I have a Main form and in the details section I have a tab control.
2. On that tab control I have put a subform. which has a combo box control.
3. when the user clicks on different tab, I am trying to change the rowsource of the combo box which is in a subform.

I don't know how to change the rowsource in the subform.

thanks
nath
 
OK - The tab Control changes things slightly, because you need to set the focus to the appropriate Tab page first.

Forms![frmTabCustomers]![TabPageName].SetFocus
Forms![frmTabCustomers]![subItems].Form.SetFocus
Forms![frmTabCustomers]![subItems].Form.[cboNames].RowSource = "tbl_Screens"

We'll get this working yet.

Hang in there!

Lightning
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top