By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,067 Members | 1,818 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,067 IT Pros & Developers. It's quick & easy.

Method Or Dta Member Not Found

P: 98
Can anyone help me with an error message i am receiving? I am trying with the code below to add a field to an existing table. My code doesn't even perform the debug. It jumps to the "fld.close" line and displays a compile error "method or data member not found". I thought maybe my table name variable was incorrect, but it won't even perform the debug. thanks for any help!

Private Sub lstTableList_AfterUpdate()
Dim db As dao.Database
Dim tbl As dao.TableDef
Dim fld As dao.Field
Dim tblClientTable As String

tblClientTable = Forms!frmDailyClient!lstTableList & "_" & MyValue
Debug.Print tblClientTable
mAnswer = MsgBox("Add a field called LS Data?", vbYesNo)
If mAnswer = 6 Then

' Start by opening the database
Set db = CurrentDb()
' Create a tabledef object
Set tbl = db.TableDefs(tblClientTable)

' Create field; set its properties; add it to the tabledef
Set fld = tbl.CreateField("LSRate", dbDouble)
tbl.Fields.Append fld

End If

Me!lstFieldList.Visible = True
Me!lstFieldList.SetFocus
Me!lstTableList.Visible = False

fld.Close
Set fld = Nothing
tbl.Close
Set tbl = Nothing
Set db = Nothing

End Sub
Oct 26 '06 #1
Share this Question
Share on Google+
3 Replies


pks00
Expert 100+
P: 280
Which line does it fall over on

Did u know u are closing fld when u havent even set it

U set fld inside a IF statement, but close it outside. That can cause a problem
Same applies to tbl
Oct 26 '06 #2

NeoPa
Expert Mod 15k+
P: 31,429
When you start to run any code, the parser will run a preliminary check through your code without compiling it.
It's checking for the obvious errors.
If it finds one it won't even start to execute the code but it will select the first line at fault and display a relevant error message.
pks00 has already drwawn your attention to certain things you need to change in your code which might explain why the parser wouldn't continue.
Oct 26 '06 #3

PEB
Expert 100+
P: 1,418
PEB
Hi

It seems that fld doesn't suport the close property

And I think that you need to close your table and your database and not your field and your table!

So the first step remove this line

The second one db.close to close the opened instance of the database!

:)
Oct 27 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.