Solved

error 459 object or class does not support the type of events

Posted on 2016-11-13
7
43 Views
Last Modified: 2016-11-13
On my application, that was perfectly working, I am suddendly getting the above error.

 


ss1
ss2

my code is:

   
    Dim strSetSQL As String

    Set sireshDB = CurrentDb
   
    strSetSQL = "SELECT tabancasMarksGPSD.codigoTabanca, tabancasMarksGPSD.codigoPonto, tabancasMarksGPSD.LatGPS AS Lat2, tabancasMarksGPSD.LgtGPS AS Lgt2, tabancasMarksGPSD.TipoPonto,  "
    strSetSQL = strSetSQL & Me.fld_latitude & " AS Lat1, " & Me.fld_longitude & " AS Lgt1,  " & Me.fld_raioLimite & " AS MaxRad, 3.14159265358979 AS Pi, "
    strSetSQL = strSetSQL & " Cos([Pi]/180*(90-[Lat1]))*Cos([Pi]/180*(90-[Lat2]))+Sin([Pi]/180*(90-[Lat1]))*Sin([Pi]/180*(90-[Lat2]))*Cos([Pi]/180*([Lgt1]-[Lgt2])) AS X, (Atn(-[X]/Sqr(-[X]*[X]+1.00000000001))+2*Atn(1))*6371000 AS CalcD "
    strSetSQL = strSetSQL & "FROM tabancasMarksGPSD; "
    Set Q27_pontosDDef = sireshDB.QueryDefs("Q27_pontosD")
    Debug.Print strSetSQL
    Q27_pontosDDef.SQL = strSetSQL
    Set Q27_pontosDSet = sireshDB.OpenRecordset("Q27_pontosD", dbOpenDynaset)
    CurrentDb.QueryDefs.Refresh
    DoEvents
    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
   
    '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)
   
    Set Q28_listaProximidadesDef = sireshDB.QueryDefs("Q28_listaProximidades")
    Q28_listaProximidadesDef.SQL = strSetSQL
    Set Q28_listaProximidadesSet = sireshDB.OpenRecordset("Q28_listaProximidades", dbOpenDynaset)
    Me.Recalc
    CurrentDb.QueryDefs.Refresh
    DoEvents
     Me.[sform_listaPontos].Form.Requery


can anyone help?
0
Comment
Question by:jirdeaid
7 Comments
 
LVL 84
ID: 41885319
Does the form where this is running have a Subform CONTROL name "sform_listaPontos"? Note I said a Subform CONTROL, which is container object on a form. Depending on how you added the Subform, Access may or may not use the form name as the name of the Subform CONTROL.

Subforms are referred to with syntax like this:

ParentForm.NameOfTheSubformCONTROL.Form.SomePropertyOrMethod

The image below show a form with Subform controls. You can determine the Name of that SubformControl by highlighting the subform (i.e. clicking on the subform to select it) and then refer to the value in the section shown by the red arrow.

Subform Name
0
 

Author Comment

by:jirdeaid
ID: 41885331
Yes... it does and I remember well the advice. It was perfectly working and I do no remember making  changes in that part of the code...


Screen-Shot-2016-11-13-at-12.58.22.png

my present code is:


Private Sub Form_Load()

DoCmd.Close acForm, "_00 base"

Dim earthRadius As Double  ' in meters

'Fórmula para calcular distâncias a partir de GPS (ignora altitude e rugosidade)
'ACOS(COS(RADIANS(90-Lat1)) *COS(RADIANS(90-Lat2)) +SIN(RADIANS(90-Lat1)) *SIN(RADIANS(90-Lat2)) *COS(RADIANS(Long1-Long2))) *6371
'ACOS(X) = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)


    Dim sireshDB As DAO.Database
    Dim Q27_pontosDSet As DAO.Recordset
    Dim Q27_pontosDDef As QueryDef
    Dim Q28_listaProximidadesSet As DAO.Recordset
    Dim Q28_listaProximidadesDef As QueryDef
   
    ' coordenadas de MAQUE
   
    Me.fld_latitude = 12.29027777777
    Me.fld_longitude = -15.3863888888
   
    ' proximidade de 1000 metros
    Me.fld_raioLimite = 1000
   
    Forms![_commonVariables]![LatGPS] = Me.fld_latitude
    Forms![_commonVariables]![LgtGPS] = Me.fld_longitude
    Forms![_commonVariables]![raioLimite] = Me.fld_raioLimite
   
   
   
    Dim strSetSQL As String

    Set sireshDB = CurrentDb
   
    strSetSQL = "SELECT tabancasMarksGPSD.codigoTabanca, tabancasMarksGPSD.codigoPonto, tabancasMarksGPSD.LatGPS AS Lat2, tabancasMarksGPSD.LgtGPS AS Lgt2, tabancasMarksGPSD.TipoPonto,  "
    strSetSQL = strSetSQL & Me.fld_latitude & " AS Lat1, " & Me.fld_longitude & " AS Lgt1,  " & Me.fld_raioLimite & " AS MaxRad, 3.14159265358979 AS Pi, "
    strSetSQL = strSetSQL & " Cos([Pi]/180*(90-[Lat1]))*Cos([Pi]/180*(90-[Lat2]))+Sin([Pi]/180*(90-[Lat1]))*Sin([Pi]/180*(90-[Lat2]))*Cos([Pi]/180*([Lgt1]-[Lgt2])) AS X, (Atn(-[X]/Sqr(-[X]*[X]+1.00000000001))+2*Atn(1))*6371000 AS CalcD "
    strSetSQL = strSetSQL & "FROM tabancasMarksGPSD; "
    Set Q27_pontosDDef = sireshDB.QueryDefs("Q27_pontosD")
    Debug.Print strSetSQL
    Q27_pontosDDef.SQL = strSetSQL
    Set Q27_pontosDSet = sireshDB.OpenRecordset("Q27_pontosD", dbOpenDynaset)
    CurrentDb.QueryDefs.Refresh
    DoEvents
    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
   
    '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)
   
    Set Q28_listaProximidadesDef = sireshDB.QueryDefs("Q28_listaProximidades")
    Q28_listaProximidadesDef.SQL = strSetSQL
    Set Q28_listaProximidadesSet = sireshDB.OpenRecordset("Q28_listaProximidades", dbOpenDynaset)
    Me.Recalc
    CurrentDb.QueryDefs.Refresh
    DoEvents
     Me.[sform_listaPontos].Form.Requery

End Sub


I just can't understand what is happening :(
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 41885366
Try to call Compact and Repair of the database.

/gustav
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
ID: 41885399
I believe you need to change the SourceObject in order to change the RecordSource once the form is displayed. Better to change the query the subform uses, refresh querydefs, and requery
0
 

Author Comment

by:jirdeaid
ID: 41885404
Hi...
now I am a bit confused.

Compact&Repair did not provide any results

what do you mean by change the source object?

my code is:

   Dim strSetSQL As String

    Set sireshDB = CurrentDb
   
    strSetSQL = "SELECT tabancasMarksGPSD.codigoTabanca, tabancasMarksGPSD.codigoPonto, tabancasMarksGPSD.LatGPS AS Lat2, tabancasMarksGPSD.LgtGPS AS Lgt2, tabancasMarksGPSD.TipoPonto,  "
    strSetSQL = strSetSQL & Me.fld_latitude & " AS Lat1, " & Me.fld_longitude & " AS Lgt1,  " & Me.fld_raioLimite & " AS MaxRad, 3.14159265358979 AS Pi, "
    strSetSQL = strSetSQL & " Cos([Pi]/180*(90-[Lat1]))*Cos([Pi]/180*(90-[Lat2]))+Sin([Pi]/180*(90-[Lat1]))*Sin([Pi]/180*(90-[Lat2]))*Cos([Pi]/180*([Lgt1]-[Lgt2])) AS X, (Atn(-[X]/Sqr(-[X]*[X]+1.00000000001))+2*Atn(1))*6371000 AS CalcD "
    strSetSQL = strSetSQL & "FROM tabancasMarksGPSD; "
    Set Q27_pontosDDef = sireshDB.QueryDefs("Q27_pontosD")
    Debug.Print strSetSQL
    Q27_pontosDDef.SQL = strSetSQL
    Set Q27_pontosDSet = sireshDB.OpenRecordset("Q27_pontosD", dbOpenDynaset)
    CurrentDb.QueryDefs.Refresh
    DoEvents
    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) & " ));"
    Debug.Print "Q28 SQL:" & strSetSQL
    Me.[sfrm_listaPontos].Form.RecordSource = strSetSQL
    Set Q28_listaProximidadesSet = sireshDB.OpenRecordset("Q28_listaProximidades", dbOpenDynaset)
    Set Q28_listaProximidadesDef = sireshDB.QueryDefs("Q28_listaProximidades")
    Q28_listaProximidadesDef.SQL = strSetSQL
    Set Q28_listaProximidadesSet = sireshDB.OpenRecordset("Q28_listaProximidades", dbOpenDynaset)
    Me.Recalc
    CurrentDb.QueryDefs.Refresh
    DoEvents
     Me.[sform_listaPontos].Form.Requery


and when I independently run the queries they look alright..
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 41885421
If C&R did not work, you can try a Decompile. To do that:

1. Make a backup of your database
2. Create a shortcut with this as the Target:

"full path to msaccess.exe" /decompile

3. Run that Shortcut, and select your Access database. Access will decompile it when you open it.
4. Open the VBA Editor and click Debug - Compile.
5. Fix any errors found, and continue doing that until the Compile option is disabled
6. Compact the database again

If that does not help then create a new, blank database and import everything into that new database.

You also may have a corrupt form. If so then you'd have to recreate the form either from a known good backup or from scratch.
0
 

Author Closing Comment

by:jirdeaid
ID: 41885454
it is working again! phew! (decompile worked out)
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

809 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