Solved

subform does update on ms/access

Posted on 2016-11-26
2
43 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 36

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
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…

820 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