Solved

subform does update on ms/access

Posted on 2016-11-26
2
31 Views
Last Modified: 2017-01-17
I have a "framing" form where I have a control that, when changed, its contents change the "where" clause of a query. They do, and when I review the query, it is OK - the correct set of records is there. This query is the data source of a  subform, that should show the set of selected records.

However, even though I use the "requery" method:

   strSetSQL = "SELECT tabancasBase.codigoTabanca, tabancasBase.NomeTabanca, tabancasBase.Programa, tabancasBase.habitatTabanca, tabancasDemografia.projPop2014, ticketCA.fechoTicket, regioesGuineBissau.nomeRegia, sectoresGuineBissau.nomeSector, tabancasBase.codigoSector "
    strSetSQL = strSetSQL & "FROM ((regioesGuineBissau INNER JOIN sectoresGuineBissau ON regioesGuineBissau.codigoRegiao = sectoresGuineBissau.codigoRegiao) INNER JOIN (tabancasBase LEFT JOIN ticketCA ON tabancasBase.codigoTabanca = ticketCA.codigoTabanca) ON (sectoresGuineBissau.codigoSector = tabancasBase.codigoSector) AND (regioesGuineBissau.codigoRegiao = tabancasBase.codigoRegiao)) LEFT JOIN tabancasDemografia ON tabancasBase.codigoTabanca = tabancasDemografia.RefTabanca "
    strSetSQL = strSetSQL & " WHERE (((sectoresGuineBissau.codigoRegiao)='"
    strSetSQL = strSetSQL & Me.fld_regiao & "'));"
    Set Q44_selectTabancaDef = sireshDB.QueryDefs("Q44_selectTabanca")
    Q44_selectTabancaDef.SQL = strSetSQL
    Set Q44_selectTabancaSet = sireshDB.OpenRecordset("Q44_selectTabanca", dbOpenDynaset)
   
    Me.[sform_listaTabancas].Form.Requery


can anyone help?
0
Comment
Question by:jirdeaid
2 Comments
 
LVL 34

Accepted Solution

by:
PatHartman earned 500 total points
ID: 41902803
I haven't ever seen this particular technique.  It might be not working because it isn't causing the subform to reload the actual query but merely rerun the existing query that it has in memory.

I use saved querydefs that reference form fields.  That doesn't require the query definition to be resaved each time.

So, the saved querydef would have the following where clause

Where sectoresGuineBissau.codigoRegiao = Forms!yourformname!fld_regiao

Another technique that I know works is to use SQL Strings as the RecordSource.  You would then replace the RecordSource --

Me.mysubformname.Form.RecordSource = strSetSQL
0
 

Author Closing Comment

by:jirdeaid
ID: 41903143
PERFECT solution. Thanks! (I have used the last option as I already had the SQL statement ready....
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
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…

919 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

18 Experts available now in Live!

Get 1:1 Help Now