passing table as parameter

G

Guest

Hello,
I'm trying to pass a table as parameter for a function. Her is my code:
Dim tabmine As TableDef
Set tabmine = Application.CurrentDb.TableDefs("tblanag")
Call Questionnaire.Collectdata(tabmine, Me)

I get an error "Object invalid or no longer set" and I have trapped that
what's wrong is in thw very first two lines (in the second one I would say).
BUt I cannot figured out what it could be.
I have surfed many posts in the forum and my code is not different from many
other.
DAOis referenced as well...

What's wrong (other than me obsession in trying to code VBA)?

Thansk,
Rocco
 
S

strive4peace

Hi Rocco,

you need to make an object reference to currentdb and use
that ...

'~~~~~~~~~~~~
dim db as dao.database, tabmine As dao.TableDef
set db = currentdb
Set tabmine = db.TableDefs("tblanag")

'or, if your parameter name is pTbldef...
Set tabmine = db.TableDefs(pTbldef)

'~~~~~~~~~~~~

then, don't forget to release your object variables at the
end of the code:

'~~~~~~~~~~~~
set tabmine = nothing
set db = nothing
'~~~~~~~~~~~~

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 
G

Guest

Thanks! it works perfectly well !!

strive4peace" <"strive4peace2006 at yaho said:
Hi Rocco,

you need to make an object reference to currentdb and use
that ...

'~~~~~~~~~~~~
dim db as dao.database, tabmine As dao.TableDef
set db = currentdb
Set tabmine = db.TableDefs("tblanag")

'or, if your parameter name is pTbldef...
Set tabmine = db.TableDefs(pTbldef)

'~~~~~~~~~~~~

then, don't forget to release your object variables at the
end of the code:

'~~~~~~~~~~~~
set tabmine = nothing
set db = nothing
'~~~~~~~~~~~~

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 
S

strive4peace

you're welcome, Rocco ;) happy to help

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 

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