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

Requery within a tab 1

Status
Not open for further replies.

oro77

Programmer
Sep 9, 2009
11
0
0
JP
Hello,

I recently began with VBA and I have some trouble to requery a combo box inside a tab.
In my main form, I use an unbound form to update the combo box. It only works one time ... if I try to update the combo box again, nothing happens.

Here is the code :

Forms!MAIN_FORM!SUB_FORM.Form.Requery

If I try to requery directly the combo box inside the tab, I got an error, it does not find the controller inside the tab.

Thanks in advance!!
 
This is more a forms question (form referencing) than VBA Coding question, ...

You say this combo is within you main form, but the reference you're showing, is how to requery a subform within a main form.

If the combo, as you say, reside within a main form, then a syntax like

[tt]Forms!TheMainForm!TheComboBox.Requery[/tt]

should do. But, the easy way to get the correct reference, would be to invoke the Expression Builder from somewhere within the form you're doing the requery. Doubleclick through Forms | Loaded Forms | the form in question and the control on the form. The resulting reference, should be something along the lines of the one demonstrated, and can be used in the code (you may wish to remove excess [brackets] for readability).

Why it only works once, may also have to do with from which event you trigger the code ...

Roy-Vidar
 
Thank you for your quick reply.

Sorry for my poor explanation but the combo box is inside a tab, this tab is in a subform.
To update the data in the combo box, I use a button a the main form which creates a pop up (unbound form). From this pop up, I update the combo box.

Anyway, I will try the Expression Builder, I am not familiar with this tool, I should search the way to use it.

PS : If I put the combo box outside the tab (but still in the subform), I am pretty sure that I can requery the combo box, so I guess that being in a tab causes the problem. There should be a trick when controller are in a tab.
 
I tried with the Expression Builder, it worked very well. Thank you so much for the help. I will use it from now when I am lost with the syntax.

Concerning my tab problem, I have just understood that a tab inside a subform, is like a subform inside a subform.
 
Good to hear you've got it sorted.

With regards to the tab, in coding or referencing, just pretend it isn't there :) You can (and probably should) reference the control as if it resides on the form or subform itself.

It is often the subform referencing that poses the challenges for many :)

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top