Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

(TableDef s) Error With Simple Code 1

Status
Not open for further replies.

xweyer

MIS
Sep 7, 2000
140
US
I'm having a strange problem relating to running code I found in another thread. The code is as follows.

dim db as dao.database
dim td as dao.tabledef
set db = currentdb
on error resume next
td = db.tabledefs("mytablename")
if err.number<>0 then
' not found - do something?
err.clear
end if

When run it hangs on the "td = db.tabledefs..." line and reports an "invalid use of property" error. I have the reference set to the MS DAO 3.6 Object Library and I can't see any problem with the code.


 
xweyer,

Tabledef is an object data type, so you must assign it with the Set keyword, just as you assigned the database object, i.e.:
Code:
dim db as dao.database
dim td as dao.tabledef
set db = currentdb
on error resume next
[highlight]Set[/highlight] td = db.tabledefs("mytablename")
if err.number<>0 then
  ' not found - do something?
  err.clear
end if
HTH,

Ken S.
 
Thanks Eupher!

I just awoke to that myself about ten minutes ago. Amazing what you don't see sometimes when its staring you right in the face.

Hate to think how much time I spent focused on the other side of that "=" sign. Thought I might have some sort of corrupted reference or other such exotic problem.

It's the little things that are killers.

You deserve a star for spotting it right off.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top