Access 2000 - Error 3219 on read access of a field property

V

Volker Uffelmann

Hi,
I've been skimming the (google) groups for a long time now and I can't find
a hint to a solution for my problem.
I have the following code:

Dim db As Database, tbl As TableDef, rel As Relation, rs As Recordset,
idx As Index, fld As Field
Set db = CurrentDb
For Each tbl In db.TableDefs
For Each idx In tbl.Indexes
If idx.Primary = True Then
For Each fld In idx.Fields

Debug.Print fld.Name
' works as expected

Debug.Print fld.Type
' error 3219 - invalid operation

' or alternatively:
' Debug.Print fld.Properties("Type").Value
' error 3219 - invalid operation

Next fld
End If
Next idx
Next tbl

The tables are directly in the mdb and I'm running Access2000 SP1a on XP Pro
SP 1 - what might cause the problem, and (even more important ;) how can I
get around it?

Any help would be greatly appreciated.

Regards,
- Volker
 
D

Duane Hookom

Make sure you have a reference to the Microsoft DAO library. Also change
your Dim to
Dim db As DAO.Database, tbl As DAO.TableDef, rel As DAO.Relation,
Dim rs As DAO.Recordset, idx As DAO.Index, fld As DAO.Field
 
V

Volker Uffelmann

Hi Duane,

that was exactly the hint I needed. :))
Thank you very, very much indeed!

Just for the logs, this is how I have it now:

Dim db As DAO.Database, tbl As DAO.TableDef
Dim idx As DAO.Index, fld As DAO.Field, idxfld As DAO.Field
For Each tbl In db.TableDefs
For Each idx In tbl.Indexes
If idx.Primary = True Then
For Each idxfld In idx.Fields
Set fld = tbl.Fields(idxfld.Name)
Debug.Print fld.Type
Next idxfld
End If
Next idx
Next tbl


It's a bit circuitous, and not exactly obvious to me, but hey, it works now!

Regards,
- Volker
 

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