Solved

ms/access subform update with refresh/requery

Posted on 2016-11-12
8
35 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:jirdeaid
  • 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 19
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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

Author Comment

by:jirdeaid
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 19

Assisted Solution

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

currentdb.querydefs.refresh
DoEvents

then Requery the form
0
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 400 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:jirdeaid
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

860 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