Solved

ms/access subform update with refresh/requery

Posted on 2016-11-12
8
24 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

23 Experts available now in Live!

Get 1:1 Help Now