calling a sub - recorset problem

hair

Registered User.
Local time
Today, 22:17
Joined
Mar 27, 2003
Messages
125
Hi

I had a big procedure and I wanted to split it out in smaller parts.

But - bad luck - I saw that if I declare the recordsets in the first sub and after I try to use them(like rc.movefirst etc) in a called sub, it ain't work.

like this:

Sub example()
Dim db as dao.database
Dim rc as dao.recordset
Set db = currentdb
Set rc = currentdb.openrecordset("mytable", dbopendynaset)

dosomething
End Sub

sub dosomething()
rc.movefirst
msgbox rc(0)
end sub

well, as you know already probably, dosomething is not doing anything. Where am I wrong?

Thanks
 
does that mean that the variables are cleared when passing the 'end sub'?
 
I found the answer of mile

Mile-O-Phile

Right at the top of your form's code module in the declarations section put your variable.


i.e.




code:--------------------------------------------------------------------------------Option Explicit
Option Compare Database

Dim MyDate As Date

Sorry for bothering
 

Users who are viewing this thread

Back
Top Bottom