Proper Code Help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ineedahelp
    New Member
    • Sep 2006
    • 98

    Proper Code Help

    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_Af terUpdate()
    Dim db As dao.Database
    Dim tbl As dao.TableDef
    Dim fld As dao.Field
    Dim tblClientTable As String

    tblClientTable = Forms!frmDailyC lient!lstTableL ist

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

    Set db = CurrentDb()

    Set tbl = db.TableDefs(tb lClientTable)

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

    End If

    'Me!lstFieldLis t.Visible = True
    'Me!lstFieldLis t.SetFocus
    Me!lstTableList .Visible = False



    End Sub
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32662

    #2
    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.

    Comment

    • ineedahelp
      New Member
      • Sep 2006
      • 98

      #3
      Thank you...I just didn't want to lead to corruption in my database because I didn't follow the proper channels!

      Comment

      Working...