Declaring variables - basic question

  • Thread starter Thread starter Will
  • Start date Start date
W

Will

I have found a number of instances in the database I have inherited where
variables have been declared "Dim rs, rh, Dt As Recordset". Does this mean
that rs, rh and Dt are all declared as recordsets or has the previous
programmer misunderstood and rs, rh are actually variants and dt is a
recordset?

Thanks in advance
 
The latter.

In some languages, including VB.NET, you can declare multiple variables in
this way, specifying the type only once at the end of the line, but in
'classic' VB and VBA you need to specify the type of each variable, or, as
you say, Variant will be used by default.
 
Brendan Reynolds said:
The latter.

In some languages, including VB.NET, you can declare multiple variables in
this way, specifying the type only once at the end of the line, but in
'classic' VB and VBA you need to specify the type of each variable, or, as
you say, Variant will be used by default.



To the OP:
And if you are going to correct this mistake, you may as well specify the
object library while you're at it. In other words, change:
Dim rs As Recordset
to either
Dim rs As DAO.Recordset
or
Dim rs As ADODB.Recordset

depending on which was intended.
 
Back
Top