CreateField error

M

Max

Hi,
I am using Access97 on Windows XP desktop and the following references:
Visual basic VBA322.DLL
Access 8.0 Object Library
Common controls 6.0
Word 10.0
DAO 2.5/3.5

The following code generates a "Method or data member not found" error on
the CreateField.

Set tdf = dbs.TableDefs!Patients
Set idx = tdf.CreateIndex("PatientIDIndex")
Set fld1 = idx.CreateField("OpNoteID")

Any ideas?

Thanks in advance,
Max
 
A

Allen Browne

The error would normally indicate that the field name does not exist, e.g.
is misspelled.

Or possibly you need to disambiguate the Field declaration, i.e.:
Dim fld1 As DAO.Field

Alternative syntax to try:
inx.Fields.Append inx.CreateField("OpNoteID")
 
M

Max

Hi Allen,

I used Dim fld1 As DAO.Field but still got the same error.
The declarations are:
Dim dbsLogdat As Database, tdf As TableDef, idx As Index, fld1 As DAO.Field


Max
 
A

Allen Browne

ADO and ADOX have an Index as well.

Try:
Dim dbsLogdat As Database, tdf As DAO.TableDef, idx As DAO.Index, fld1 As
DAO.Field
 
M

Max

Thanks Allen,
That helped with this bit code.
Now other errors have come up that were not previously a problem. I suspect
I have a references problem.
Running through Doug Steele's very helpful pages.

Max
 

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

Similar Threads


Top