First of all, 'dumb' questions are inevitable sometimes, so you dont need
the 'Forgive Me'
Second, it helps the rest of us figure out what kind of dumb question you
are asking if you give a more meaningful Subject line.
Thirdly, it's not really much of a dumb question at all.
Given this example, you don't need to declare New_app as a recordset, but
you are entitled to. There are times where it is useful/necessary, e.g if
you explicitly declare a variable as a recordset, intellisense can then list
the properties and methods for you.
Yes, this runs the 'Set New_app' code twice but it is doing two different
things:
- The first line states that you want New_app to hold an empty recordset.
- The conn.Execute in the second line returns a recordset that is then
stored in New_app.
In this example you *can* miss out the first Set statement.
There are other techniques and styles in common use, in which case declare a
variable explicitly in this way is needed.
hth
Chris
"Luis" <an****@webmail.co.za> wrote in message
news:69**************************@posting.google.c om...
A dumb friday-afternoon-and-I-need-a-weekend question.
I inherited an application that has code similar to:
set conn = server.CreateObject("ADODB.Connection")
set New_app = server.CreateObject("ADODB.Recordset")
set New_app = conn.Execute("SELECT * FROM TableName WHERE Blah = '"&
blah & "'")
The code executes a "set New_app" instruction TWO TIMES. Doesn't the
second "set New_app" instruction override the first "set New_app"
instruction?
And is it correct that the
set New_app = server.CreateObject("ADODB.Recordset")
instruction is totally unnecessary anyway?
Thanks