Create Access table using VB6 code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MarkTingson
    New Member
    • Nov 2007
    • 40

    Create Access table using VB6 code

    Hello guys,

    im having trouble with this line of code. I'm trying to create a table in access using this piece of code but it says 'Object is no longer valid.' and it points to ocat.Tables.App end otbl. How can I solve this error guys?

    Heres the code:

    Dim otbl As New ADOX.Table
    Dim ocat As New ADOX.Catalog

    otbl.Name = "Table1"
    otbl.Columns.Ap pend "strItemCod e", adChar
    otbl.Columns.Ap pend "strItemNam e", adChar
    otbl.Columns.Ap pend "intTotalQt y", adInteger
    otbl.Columns.Ap pend "intPullOut ", adInteger
    otbl.Columns.Ap pend "intTotalAm t", adInteger '
    ocat.Tables.App end otbl
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    try using this
    [code=vb]
    ocat.ActiveConn ection = con ''your connection object
    otbl.ParentCata log = ocat
    [/code]

    might help you.

    Comment

    • MarkTingson
      New Member
      • Nov 2007
      • 40

      #3
      Originally posted by debasisdas
      try using this
      [code=vb]
      ocat.ActiveConn ection = con ''your connection object
      otbl.ParentCata log = ocat
      [/code]

      might help you.
      I already put the code but it says ''Type is invalid" and points to ocat.Tables.App end otbl...

      I think I have put otbl.Type=?????

      What kind of type is that? And what does otbl.ParentCata log means?

      Comment

      • MarkTingson
        New Member
        • Nov 2007
        • 40

        #4
        Okay.. I have solved my problem.. i just put set otbl = new ADOX.Catalog and it works! Now my problem is, how to set its Default Value=0?? Any suggestions sir?

        Comment

        • debasisdas
          Recognized Expert Expert
          • Dec 2006
          • 8119

          #5
          Default Value Of What ?

          Comment

          • MarkTingson
            New Member
            • Nov 2007
            • 40

            #6
            Originally posted by debasisdas
            Default Value Of What ?
            Hehe.. i already solve my problem :
            [code=vb]
            otbl.Columns("i ntTotalQty").Pr operties("Defau lt") = 0
            otbl.Columns("i ntPullOut").Pro perties("Defaul t") = 0
            otbl.Columns("i ntTotalAmt").Pr operties("Defau lt") = 0
            [/code]
            Thanks for giving a little idea sir.. :)
            Last edited by debasisdas; Feb 27 '08, 09:08 AM. Reason: added code=vb tags

            Comment

            Working...