Solved

ms/access subform update with refresh/requery

Posted on 2016-11-12
8
27 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 119

Expert Comment

by:Rey Obrero
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 119

Expert Comment

by:Rey Obrero
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
 

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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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 119

Expert Comment

by:Rey Obrero
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now