João serras-pereira
asked on
error 459 object or class does not support the type of events
On my application, that was perfectly working, I am suddendly getting the above error.
my code is:
Dim strSetSQL As String
Set sireshDB = CurrentDb
strSetSQL = "SELECT tabancasMarksGPSD.codigoTa banca, tabancasMarksGPSD.codigoPo nto, tabancasMarksGPSD.LatGPS AS Lat2, tabancasMarksGPSD.LgtGPS AS Lgt2, tabancasMarksGPSD.TipoPont o, "
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]/1 80*(90-[La t2]))+Sin( [Pi]/180*( 90-[Lat1]) )*Sin([Pi] /180*(90-[ Lat2]))*Co s([Pi]/180 *([Lgt1]-[ Lgt2])) AS X, (Atn(-[X]/Sqr(-[X]*[X]+1.0 0000000001 ))+2*Atn(1 ))*6371000 AS CalcD "
strSetSQL = strSetSQL & "FROM tabancasMarksGPSD; "
Set Q27_pontosDDef = sireshDB.QueryDefs("Q27_po ntosD")
Debug.Print strSetSQL
Q27_pontosDDef.SQL = strSetSQL
Set Q27_pontosDSet = sireshDB.OpenRecordset("Q2 7_pontosD" , dbOpenDynaset)
CurrentDb.QueryDefs.Refres h
DoEvents
strSetSQL = "SELECT Q27_pontosD.codigoTabanca, Q27_pontosD.codigoPonto, Q27_pontosD.TipoPonto, tabancasBase.NomeTabanca, sectoresGuineBissau.nomeSe ctor, regioesGuineBissau.nomeReg ia, Q27_pontosD.CalcD "
strSetSQL = strSetSQL & "FROM (regioesGuineBissau INNER JOIN (Q27_pontosD INNER JOIN tabancasBase ON Q27_pontosD.codigoTabanca = tabancasBase.codigoTabanca ) ON regioesGuineBissau.codigoR egiao = tabancasBase.codigoRegiao) INNER JOIN sectoresGuineBissau ON (sectoresGuineBissau.codig oSector = tabancasBase.codigoSector) AND (regioesGuineBissau.codigo Regiao = sectoresGuineBissau.codigo Regiao) "
strSetSQL = strSetSQL & "WHERE (((Q27_pontosD.CalcD)< "
strSetSQL = strSetSQL & Nz(Me.fld_raioLimite, 10) & " ));"
Me.[sform_listaPontos].For m.RecordSo urce = strSetSQL
'strSetSQL = "SELECT Q27_pontosD.codigoTabanca, Q27_pontosD.codigoPonto, Q27_pontosD.TipoPonto, tabancasBase.NomeTabanca, sectoresGuineBissau.nomeSe ctor, regioesGuineBissau.nomeReg ia, Q27_pontosD.CalcD "
'strSetSQL = strSetSQL & "FROM (regioesGuineBissau INNER JOIN (Q27_pontosD INNER JOIN tabancasBase ON Q27_pontosD.codigoTabanca = tabancasBase.codigoTabanca ) ON regioesGuineBissau.codigoR egiao = tabancasBase.codigoRegiao) INNER JOIN sectoresGuineBissau ON (sectoresGuineBissau.codig oSector = tabancasBase.codigoSector) AND (regioesGuineBissau.codigo Regiao = sectoresGuineBissau.codigo Regiao) "
'strSetSQL = strSetSQL & "WHERE (((Q27_pontosD.CalcD)< "
'strSetSQL = strSetSQL & Nz(Me.fld_raioLimite, 10) & " ));"
'Set Q28_listaProximidadesDef = sireshDB.QueryDefs("Q28_li staProximi dades")
'Q28_listaProximidadesDef. SQL = strSetSQL
Set Q28_listaProximidadesSet = sireshDB.OpenRecordset("Q2 8_listaPro ximidades" , dbOpenDynaset)
Set Q28_listaProximidadesDef = sireshDB.QueryDefs("Q28_li staProximi dades")
Q28_listaProximidadesDef.S QL = strSetSQL
Set Q28_listaProximidadesSet = sireshDB.OpenRecordset("Q2 8_listaPro ximidades" , dbOpenDynaset)
Me.Recalc
CurrentDb.QueryDefs.Refres h
DoEvents
Me.[sform_listaPontos].For m.Requery
can anyone help?
my code is:
Dim strSetSQL As String
Set sireshDB = CurrentDb
strSetSQL = "SELECT tabancasMarksGPSD.codigoTa
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]))*
strSetSQL = strSetSQL & "FROM tabancasMarksGPSD; "
Set Q27_pontosDDef = sireshDB.QueryDefs("Q27_po
Debug.Print strSetSQL
Q27_pontosDDef.SQL = strSetSQL
Set Q27_pontosDSet = sireshDB.OpenRecordset("Q2
CurrentDb.QueryDefs.Refres
DoEvents
strSetSQL = "SELECT Q27_pontosD.codigoTabanca,
strSetSQL = strSetSQL & "FROM (regioesGuineBissau INNER JOIN (Q27_pontosD INNER JOIN tabancasBase ON Q27_pontosD.codigoTabanca = tabancasBase.codigoTabanca
strSetSQL = strSetSQL & "WHERE (((Q27_pontosD.CalcD)< "
strSetSQL = strSetSQL & Nz(Me.fld_raioLimite, 10) & " ));"
Me.[sform_listaPontos].For
'strSetSQL = "SELECT Q27_pontosD.codigoTabanca,
'strSetSQL = strSetSQL & "FROM (regioesGuineBissau INNER JOIN (Q27_pontosD INNER JOIN tabancasBase ON Q27_pontosD.codigoTabanca = tabancasBase.codigoTabanca
'strSetSQL = strSetSQL & "WHERE (((Q27_pontosD.CalcD)< "
'strSetSQL = strSetSQL & Nz(Me.fld_raioLimite, 10) & " ));"
'Set Q28_listaProximidadesDef = sireshDB.QueryDefs("Q28_li
'Q28_listaProximidadesDef.
Set Q28_listaProximidadesSet = sireshDB.OpenRecordset("Q2
Set Q28_listaProximidadesDef = sireshDB.QueryDefs("Q28_li
Q28_listaProximidadesDef.S
Set Q28_listaProximidadesSet = sireshDB.OpenRecordset("Q2
Me.Recalc
CurrentDb.QueryDefs.Refres
DoEvents
Me.[sform_listaPontos].For
can anyone help?
ASKER
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...
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.codigoTa banca, tabancasMarksGPSD.codigoPo nto, tabancasMarksGPSD.LatGPS AS Lat2, tabancasMarksGPSD.LgtGPS AS Lgt2, tabancasMarksGPSD.TipoPont o, "
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]/1 80*(90-[La t2]))+Sin( [Pi]/180*( 90-[Lat1]) )*Sin([Pi] /180*(90-[ Lat2]))*Co s([Pi]/180 *([Lgt1]-[ Lgt2])) AS X, (Atn(-[X]/Sqr(-[X]*[X]+1.0 0000000001 ))+2*Atn(1 ))*6371000 AS CalcD "
strSetSQL = strSetSQL & "FROM tabancasMarksGPSD; "
Set Q27_pontosDDef = sireshDB.QueryDefs("Q27_po ntosD")
Debug.Print strSetSQL
Q27_pontosDDef.SQL = strSetSQL
Set Q27_pontosDSet = sireshDB.OpenRecordset("Q2 7_pontosD" , dbOpenDynaset)
CurrentDb.QueryDefs.Refres h
DoEvents
strSetSQL = "SELECT Q27_pontosD.codigoTabanca, Q27_pontosD.codigoPonto, Q27_pontosD.TipoPonto, tabancasBase.NomeTabanca, sectoresGuineBissau.nomeSe ctor, regioesGuineBissau.nomeReg ia, Q27_pontosD.CalcD "
strSetSQL = strSetSQL & "FROM (regioesGuineBissau INNER JOIN (Q27_pontosD INNER JOIN tabancasBase ON Q27_pontosD.codigoTabanca = tabancasBase.codigoTabanca ) ON regioesGuineBissau.codigoR egiao = tabancasBase.codigoRegiao) INNER JOIN sectoresGuineBissau ON (sectoresGuineBissau.codig oSector = tabancasBase.codigoSector) AND (regioesGuineBissau.codigo Regiao = sectoresGuineBissau.codigo Regiao) "
strSetSQL = strSetSQL & "WHERE (((Q27_pontosD.CalcD)< "
strSetSQL = strSetSQL & Nz(Me.fld_raioLimite, 10) & " ));"
Me.[sform_listaPontos].For m.RecordSo urce = strSetSQL
'strSetSQL = "SELECT Q27_pontosD.codigoTabanca, Q27_pontosD.codigoPonto, Q27_pontosD.TipoPonto, tabancasBase.NomeTabanca, sectoresGuineBissau.nomeSe ctor, regioesGuineBissau.nomeReg ia, Q27_pontosD.CalcD "
'strSetSQL = strSetSQL & "FROM (regioesGuineBissau INNER JOIN (Q27_pontosD INNER JOIN tabancasBase ON Q27_pontosD.codigoTabanca = tabancasBase.codigoTabanca ) ON regioesGuineBissau.codigoR egiao = tabancasBase.codigoRegiao) INNER JOIN sectoresGuineBissau ON (sectoresGuineBissau.codig oSector = tabancasBase.codigoSector) AND (regioesGuineBissau.codigo Regiao = sectoresGuineBissau.codigo Regiao) "
'strSetSQL = strSetSQL & "WHERE (((Q27_pontosD.CalcD)< "
'strSetSQL = strSetSQL & Nz(Me.fld_raioLimite, 10) & " ));"
'Set Q28_listaProximidadesDef = sireshDB.QueryDefs("Q28_li staProximi dades")
'Q28_listaProximidadesDef. SQL = strSetSQL
Set Q28_listaProximidadesSet = sireshDB.OpenRecordset("Q2 8_listaPro ximidades" , dbOpenDynaset)
Set Q28_listaProximidadesDef = sireshDB.QueryDefs("Q28_li staProximi dades")
Q28_listaProximidadesDef.S QL = strSetSQL
Set Q28_listaProximidadesSet = sireshDB.OpenRecordset("Q2 8_listaPro ximidades" , dbOpenDynaset)
Me.Recalc
CurrentDb.QueryDefs.Refres h
DoEvents
Me.[sform_listaPontos].For m.Requery
End Sub
I just can't understand what is happening :(
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)
'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]![
Forms![_commonVariables]![
Forms![_commonVariables]![
Dim strSetSQL As String
Set sireshDB = CurrentDb
strSetSQL = "SELECT tabancasMarksGPSD.codigoTa
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]))*
strSetSQL = strSetSQL & "FROM tabancasMarksGPSD; "
Set Q27_pontosDDef = sireshDB.QueryDefs("Q27_po
Debug.Print strSetSQL
Q27_pontosDDef.SQL = strSetSQL
Set Q27_pontosDSet = sireshDB.OpenRecordset("Q2
CurrentDb.QueryDefs.Refres
DoEvents
strSetSQL = "SELECT Q27_pontosD.codigoTabanca,
strSetSQL = strSetSQL & "FROM (regioesGuineBissau INNER JOIN (Q27_pontosD INNER JOIN tabancasBase ON Q27_pontosD.codigoTabanca = tabancasBase.codigoTabanca
strSetSQL = strSetSQL & "WHERE (((Q27_pontosD.CalcD)< "
strSetSQL = strSetSQL & Nz(Me.fld_raioLimite, 10) & " ));"
Me.[sform_listaPontos].For
'strSetSQL = "SELECT Q27_pontosD.codigoTabanca,
'strSetSQL = strSetSQL & "FROM (regioesGuineBissau INNER JOIN (Q27_pontosD INNER JOIN tabancasBase ON Q27_pontosD.codigoTabanca = tabancasBase.codigoTabanca
'strSetSQL = strSetSQL & "WHERE (((Q27_pontosD.CalcD)< "
'strSetSQL = strSetSQL & Nz(Me.fld_raioLimite, 10) & " ));"
'Set Q28_listaProximidadesDef = sireshDB.QueryDefs("Q28_li
'Q28_listaProximidadesDef.
Set Q28_listaProximidadesSet = sireshDB.OpenRecordset("Q2
Set Q28_listaProximidadesDef = sireshDB.QueryDefs("Q28_li
Q28_listaProximidadesDef.S
Set Q28_listaProximidadesSet = sireshDB.OpenRecordset("Q2
Me.Recalc
CurrentDb.QueryDefs.Refres
DoEvents
Me.[sform_listaPontos].For
End Sub
I just can't understand what is happening :(
Try to call Compact and Repair of the database.
/gustav
/gustav
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
ASKER
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.codigoTa banca, tabancasMarksGPSD.codigoPo nto, tabancasMarksGPSD.LatGPS AS Lat2, tabancasMarksGPSD.LgtGPS AS Lgt2, tabancasMarksGPSD.TipoPont o, "
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]/1 80*(90-[La t2]))+Sin( [Pi]/180*( 90-[Lat1]) )*Sin([Pi] /180*(90-[ Lat2]))*Co s([Pi]/180 *([Lgt1]-[ Lgt2])) AS X, (Atn(-[X]/Sqr(-[X]*[X]+1.0 0000000001 ))+2*Atn(1 ))*6371000 AS CalcD "
strSetSQL = strSetSQL & "FROM tabancasMarksGPSD; "
Set Q27_pontosDDef = sireshDB.QueryDefs("Q27_po ntosD")
Debug.Print strSetSQL
Q27_pontosDDef.SQL = strSetSQL
Set Q27_pontosDSet = sireshDB.OpenRecordset("Q2 7_pontosD" , dbOpenDynaset)
CurrentDb.QueryDefs.Refres h
DoEvents
strSetSQL = "SELECT Q27_pontosD.codigoTabanca, Q27_pontosD.codigoPonto, Q27_pontosD.TipoPonto, tabancasBase.NomeTabanca, sectoresGuineBissau.nomeSe ctor, regioesGuineBissau.nomeReg ia, Q27_pontosD.CalcD "
strSetSQL = strSetSQL & "FROM (regioesGuineBissau INNER JOIN (Q27_pontosD INNER JOIN tabancasBase ON Q27_pontosD.codigoTabanca = tabancasBase.codigoTabanca ) ON regioesGuineBissau.codigoR egiao = tabancasBase.codigoRegiao) INNER JOIN sectoresGuineBissau ON (sectoresGuineBissau.codig oSector = tabancasBase.codigoSector) AND (regioesGuineBissau.codigo Regiao = sectoresGuineBissau.codigo Regiao) "
strSetSQL = strSetSQL & "WHERE (((Q27_pontosD.CalcD)< "
strSetSQL = strSetSQL & Nz(Me.fld_raioLimite, 10) & " ));"
Debug.Print "Q28 SQL:" & strSetSQL
Me.[sfrm_listaPontos].Form .RecordSou rce = strSetSQL
Set Q28_listaProximidadesSet = sireshDB.OpenRecordset("Q2 8_listaPro ximidades" , dbOpenDynaset)
Set Q28_listaProximidadesDef = sireshDB.QueryDefs("Q28_li staProximi dades")
Q28_listaProximidadesDef.S QL = strSetSQL
Set Q28_listaProximidadesSet = sireshDB.OpenRecordset("Q2 8_listaPro ximidades" , dbOpenDynaset)
Me.Recalc
CurrentDb.QueryDefs.Refres h
DoEvents
Me.[sform_listaPontos].For m.Requery
and when I independently run the queries they look alright..
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.codigoTa
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]))*
strSetSQL = strSetSQL & "FROM tabancasMarksGPSD; "
Set Q27_pontosDDef = sireshDB.QueryDefs("Q27_po
Debug.Print strSetSQL
Q27_pontosDDef.SQL = strSetSQL
Set Q27_pontosDSet = sireshDB.OpenRecordset("Q2
CurrentDb.QueryDefs.Refres
DoEvents
strSetSQL = "SELECT Q27_pontosD.codigoTabanca,
strSetSQL = strSetSQL & "FROM (regioesGuineBissau INNER JOIN (Q27_pontosD INNER JOIN tabancasBase ON Q27_pontosD.codigoTabanca = tabancasBase.codigoTabanca
strSetSQL = strSetSQL & "WHERE (((Q27_pontosD.CalcD)< "
strSetSQL = strSetSQL & Nz(Me.fld_raioLimite, 10) & " ));"
Debug.Print "Q28 SQL:" & strSetSQL
Me.[sfrm_listaPontos].Form
Set Q28_listaProximidadesSet = sireshDB.OpenRecordset("Q2
Set Q28_listaProximidadesDef = sireshDB.QueryDefs("Q28_li
Q28_listaProximidadesDef.S
Set Q28_listaProximidadesSet = sireshDB.OpenRecordset("Q2
Me.Recalc
CurrentDb.QueryDefs.Refres
DoEvents
Me.[sform_listaPontos].For
and when I independently run the queries they look alright..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
it is working again! phew! (decompile worked out)
Subforms are referred to with syntax like this:
ParentForm.NameOfTheSubfor
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.