Declaring variables - basic question

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
 
B

Brendan Reynolds

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.
 
B

Brian Wilson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top