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!

Requery Action- HELP! 1

Status
Not open for further replies.

hthagood

Technical User
Jul 5, 2011
9
US
I have an unbound main form with tabs that have my various forms for my application. I am having an issue with the data not refreshing; I think I need to be using the requery action, not the refresh. I guess I have two questions:

1. Is there a way to generically "Requery" form data when I click on each tab in my main form? I have tried to create a macro with just "Requery" in it, and putting it in OnActivate, OnLoad, etc., but nothing seems to work.

2. What is the proper syntax to refresh a combo/list box? Here are my specifics: I have a main form "frmMain" that has tabs with unbound forms. One subform is "frmBudgetMaintenance" with a subform "frmProjectLineItems" that has a combo/list box "text16". I can't arrange the Requery call in VBA correctly.

Also, one last thing, is there a way to mimic the "Refresh All" button in the ribbon with VBA? That seems to always fix the issue I am dealing with.
 
Requery, refresh, or save can't work on an unbound form. There is nothing to requery save the controls themselves. Those commands work on the underlying dataset.

To refresh a control, use a macro. GotoControl, and Refresh. But again, if it's not bound what are you refreshing?
 
the controls are bound to the form/subform, I just have them on an unbound 'main' form that is tabbed. Where is the best place to run the macro? In the actual control?
 
The best place is based on when you want the control refreshed. Is it after the update of another control, when you close the form, etc? You trigger it at the point you want to execute it.
 
Here's my problem; I have a tabbed form (frmMain) that has several unbound subforms and most of those forms have subforms. One tab has frmBudgetSetUp where I want to requery a list box on two other forms after I create a record (I have other code that creates the record). I can't get the requery to work.

The two list boxes I want to update are:
frmBudgetMaintenance.frmProjectLineItemsMaint.Text16
frmBudgetMaintenancePREDEVELOPMENT.frmProjectLineItemsMaintPREDEVELOPMENT.Text16

And I want to call it from frmBudgetSetUp

And all sit in tabs (unbound) to frmMain

Help! This is driving me crazy.
 
Well, if you want to call the requery or refresh action from a different form, you'd so so like this:

Forms!frmMyFormName.Requery

Or Forms!frmMyFormName!MyControlName.Requery

Or something along those lines.. I'm just typing, not testing what I type...

I can try testing it for you later if I am able... see if that works for you at all..
 
Also... if that route doesn't work, try setting the focus to the given form/subform.. then to the given control if necessary.
 
Glad you got it sorted out, and thanks for posting a follow-up showing how you got it sorted out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top