?
Solved

ms/access subform update with refresh/requery

Posted on 2016-11-12
8
Medium Priority
?
74 Views
Last Modified: 2016-11-13
I am facing a challenge with a special subform that I have developed - it does not update to the query to which is bounded.

On the masterform I have some fields that, upon being filled/updated, do generate a set of two sequential queries, the second one being bounded to the subform.

On masterform load everything works fine and the queries based on the updated  fields are ran and output RST is what is expected. However, in the subform, only the original RST is shown. I have Me.refresh / Me.Recalc whenever I update the fields and run the queries. But I do not know to to force the subform refres/recalc/requery (if that is the solution)

can anyone help?
0
Comment
Question by:João serras-pereira
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 41884877
calling the requery of the subform from the main form,  you have to refer to the subform control

me.[subformcontrolName].form.requery
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 41884879
oops, replace the subformControlName with the name of the control where the subform is.
in most cases it is also the name of the subform.
to find the name of the subform control name, open the main form in design view and select the control by clicking on the edge of the subform, hit F4 and on the Other tab look at the Name property and use what is listed there as the name of the subform control
0
 
LVL 23
ID: 41884896
adding on about Name property of a subform control:

If the subform has a caption or information in the autotitle label, it may be used for the name.  Copy what is in the Source Object property to the Name property so they are both the same.  Both of those properties are at the top of the All tab on the Property Sheet for the subform control.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:João serras-pereira
ID: 41884921
I must be doing something really bad. Just after executing the queries, I conform that the output is OK.

please check the screenshot:


ss1
my code is:



    Debug.Print "Proximidade:" & Me.fld_raioLimite & " metros"
 
    Set Q28_listaProximidadesSet = sireshDB.OpenRecordset("Q28_listaProximidades", dbOpenDynaset)
    strSetSQL = "SELECT Q27_pontosD.codigoTabanca, Q27_pontosD.codigoPonto, Q27_pontosD.TipoPonto, tabancasBase.NomeTabanca, sectoresGuineBissau.nomeSector, regioesGuineBissau.nomeRegia, Q27_pontosD.CalcD "
    strSetSQL = strSetSQL & "FROM (regioesGuineBissau INNER JOIN (Q27_pontosD INNER JOIN tabancasBase ON Q27_pontosD.codigoTabanca = tabancasBase.codigoTabanca) ON regioesGuineBissau.codigoRegiao = tabancasBase.codigoRegiao) INNER JOIN sectoresGuineBissau ON (sectoresGuineBissau.codigoSector = tabancasBase.codigoSector) AND (regioesGuineBissau.codigoRegiao = sectoresGuineBissau.codigoRegiao) "
    strSetSQL = strSetSQL & "WHERE (((Q27_pontosD.CalcD)< "
    strSetSQL = strSetSQL & Nz(Me.fld_raioLimite, 10) & " ));"
    Set Q28_listaProximidadesDef = sireshDB.QueryDefs("Q28_listaProximidades")
    Q28_listaProximidadesDef.SQL = strSetSQL
    Set Q28_listaProximidadesSet = sireshDB.OpenRecordset("Q28_listaProximidades", dbOpenDynaset)
    Me.Refresh
    Me.[sform_listaPontos].Form.Requery


so, just after querying I should see the updated RST.

But now - it always shows the previous RST (!) even when I reload the form..

should it be another method?
0
 
LVL 23

Assisted Solution

by:crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access earned 400 total points
ID: 41884936
after you change a querydef:

currentdb.querydefs.refresh
DoEvents

then Requery the form
0
 
LVL 52

Accepted Solution

by:
Gustav Brock earned 1600 total points
ID: 41884941
You are just adjusting the SQL of some queries and opening some recordsets unrelated to the subform.

Try this:
strSetSQL = "SELECT Q27_pontosD.codigoTabanca, Q27_pontosD.codigoPonto, Q27_pontosD.TipoPonto, tabancasBase.NomeTabanca, sectoresGuineBissau.nomeSector, regioesGuineBissau.nomeRegia, Q27_pontosD.CalcD "
    strSetSQL = strSetSQL & "FROM (regioesGuineBissau INNER JOIN (Q27_pontosD INNER JOIN tabancasBase ON Q27_pontosD.codigoTabanca = tabancasBase.codigoTabanca) ON regioesGuineBissau.codigoRegiao = tabancasBase.codigoRegiao) INNER JOIN sectoresGuineBissau ON (sectoresGuineBissau.codigoSector = tabancasBase.codigoSector) AND (regioesGuineBissau.codigoRegiao = sectoresGuineBissau.codigoRegiao) "
    strSetSQL = strSetSQL & "WHERE (((Q27_pontosD.CalcD)< "
    strSetSQL = strSetSQL & Nz(Me.fld_raioLimite, 10) & " ));"

Me.[sform_listaPontos].Form.RecordSource = strSetSQL

Open in new window

/gustav
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 41884957
check the Record Source of the subform..
is it the query "Q28_listaProximidades"
0
 

Author Closing Comment

by:João serras-pereira
ID: 41885159
Hi all! Thanks a lot. Gustav's solution got it working.

Just a side question: I have some unanswered questions. In the old days, after some time (? 48h) I could press a button to request attention to the question. where is this button now?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question