Access 2007 create index by vb

nuritat
nuritat used Ask the Experts™
on
Hi
I'm trying to create an index to a table on Access 2007
like this:

Set idx = tdf.CreateIndex("PrimaryKey")
With idx
     .Fields.Append .CreateField("field1")
     .Fields.Append .CreateField("field2")
End With
idx.Primary = True
tdf.Indexes.Append idx

it used to work for me on earlier versions of access but now I get an error on " .CreateField"
saying: "Method or data memeber not found"

any idea?

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
CHeck that you've got a reference to the DAO library.  Then disambiguate (naff term) your variables i.e.

Dim idx As DAO.Index

Author

Commented:
Thanks

adding the DAO.index was enough

Author

Commented:
I'd like to aword the points
Should you be charging more for IT Services?

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Commented:
I think you closed this question by mistake.  You can generate a request in Community Support for Moderator review to reverse this.

Author

Commented:
No, It was not a mistake, the answer was perfect I even awarded the points already, why should I open it again?
Commented:
Hi nuritat.  I got a email saying the question I'd participated in would be clode in 4 days & the points haven't been awarded to myself.  If I've made a mistake, I apologise.

Author

Commented:
I already awarded the pointes twice,  whats worng?

Commented:
Hi nuritat.  It seems to be sorted now.  Thankyou.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial