Solved

subform does update on ms/access

Posted on 2016-11-26
2
57 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 38

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

634 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