Wondering if there is ANY difference in the way in which the following different versions of the same code are executed.
As in is it better to create a CurrentDB variable and execute the query using that or just use CurrentDB directly. This might be a stupid question but it just seemed a bit silly to define a variable, set it, use it and then clear it when the same can be achieved in 1 line of VBA
again might be that there is no difference and it comes down to preference and if so great, but if there is a definitive "best practice" when it comes to these sorts of things i'd appreciate the collective wisdom of this place pointing me in the right direction
Kind regards
Glen
Code:
Dim db as database
set db = CurrentDb
db.Execute "UPDATE [FACT-DeliveryInvoicesAndCNs] SET " & trimSelection("," & SQL) & " WHERE [FACT-DeliveryInvoicesAndCNs].id In (" & trimSelection(Me.txtSelected) & ");", dbFailOnError
set db = nothing
OR
CurrentDb.Execute "UPDATE [FACT-DeliveryInvoicesAndCNs] SET " & trimSelection("," & SQL) & " WHERE [FACT-DeliveryInvoicesAndCNs].id In (" & trimSelection(Me.txtSelected) & ");", dbFailOnError
As in is it better to create a CurrentDB variable and execute the query using that or just use CurrentDB directly. This might be a stupid question but it just seemed a bit silly to define a variable, set it, use it and then clear it when the same can be achieved in 1 line of VBA
again might be that there is no difference and it comes down to preference and if so great, but if there is a definitive "best practice" when it comes to these sorts of things i'd appreciate the collective wisdom of this place pointing me in the right direction
Kind regards
Glen