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

Proper Code Help

P: 98
the program listed below runs and does what I want it to when I DO NOT INCLUDE the 2 "close" statements, but it gives me a "Member Not Found" error when I include the lines "fld.close" and "tbl.close". Can anyone tell me if I need these lines as a method of proper coding or have I used them improperly. I really want to understand how to code properly. Thank you 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

Debug.Print tblClientTable & "tblclienttable"
mAnswer = MsgBox("Add a field called LS Data?", vbYesNo)
If mAnswer = 6 Then

Set db = CurrentDb()

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
'fld.Close
'tbl.Close
Set fld = Nothing
Set tbl = Nothing
Set db = Nothing

End If

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



End Sub
Oct 27 '06 #1
Share this Question
Share on Google+
2 Replies


NeoPa
Expert Mod 15k+
P: 31,475
As I understand it, you don't need to close Fields or TableDefs.
A RecordSet built on a TableDef would be different, although, even in that case the close would happen automatically when you set the last object reference to Nothing.
Oct 27 '06 #2

P: 98
Thank you...I just didn't want to lead to corruption in my database because I didn't follow the proper channels!
Oct 27 '06 #3

Post your reply

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