Could someone please help me?
In the following code I get object invalid or no longer set error.
I would like to update some records after updating a discount text field (popust_A) without any confirmation window or something like by "runsql" object.
---------------------------------
Private Sub popust_a_AfterUpdate()
Dim dbs As Database, qdf As QueryDef
Dim pop, popkof As Single
Dim popkofstring, strsql, pon as String
IDPonudbe = Me.ponudba
popA = Me.popust_a
popkof = 1 - (Me.popust_a / 100)
popkofstring = Str(popkof)
pon = Str(IDPonudbe)
Set dbs = CurrentDb
strSQL = "UPDATE Cenik_PPL_tbl INNER JOIN podsklop_referenca ON Cenik_PPL_tbl.REF = podsklop_referenca.ref SET podsklop_referenca.znesek = [podsklop_referenca].[cena]*[podsklop_referenca].[kolicina]*" & popkofstring & " WHERE (((podsklop_referenca.grupa1)='A') AND ((podsklop_referenca.[#ponudbe])=" & pon & ");"
Set qdf = dbs.CreateQueryDef(, strSQL)
qdf.Execute <-- here is the problem
Set dbs = Nothing
End Sub
In the following code I get object invalid or no longer set error.
I would like to update some records after updating a discount text field (popust_A) without any confirmation window or something like by "runsql" object.
---------------------------------
Private Sub popust_a_AfterUpdate()
Dim dbs As Database, qdf As QueryDef
Dim pop, popkof As Single
Dim popkofstring, strsql, pon as String
IDPonudbe = Me.ponudba
popA = Me.popust_a
popkof = 1 - (Me.popust_a / 100)
popkofstring = Str(popkof)
pon = Str(IDPonudbe)
Set dbs = CurrentDb
strSQL = "UPDATE Cenik_PPL_tbl INNER JOIN podsklop_referenca ON Cenik_PPL_tbl.REF = podsklop_referenca.ref SET podsklop_referenca.znesek = [podsklop_referenca].[cena]*[podsklop_referenca].[kolicina]*" & popkofstring & " WHERE (((podsklop_referenca.grupa1)='A') AND ((podsklop_referenca.[#ponudbe])=" & pon & ");"
Set qdf = dbs.CreateQueryDef(, strSQL)
qdf.Execute <-- here is the problem
Set dbs = Nothing
End Sub