Results 1 to 7 of 7

Thread: Access CreateField

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    Brossard, Québec, Canada
    Posts
    241

    Access CreateField

    I am using CreateField to add a Date field to an existing table in Access. When I execute the code, everything seems fine but in reality, the field is not created.

    Why is that?

    Note: The name of the table is valid and I have checked to see if access finds it.

    here's my code:
    Code:
    Public Sub DoTableUpdate()
        Dim dbs As Database
        
        Set dbs = OpenDatabase("C:\Documents and Settings\dlaplante\Desktop\Syndata\Database\SynagisData.mdb")
        dbs.TableDefs("Shipment").CreateField "Shipment_NextDate", dbDate
        dbs.Close
        Set dbs = Nothing
    End Sub

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    I think u have to Append the field.
    -= a peet post =-

  3. #3
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    try doing it this way :

    VB Code:
    1. Public Sub DoTableUpdate()
    2.     Dim dbs As Database
    3.     Dim f As Field
    4.    
    5.     Set dbs = OpenDatabase("C:\Documents and Settings\dlaplante\Desktop\Syndata\Database\SynagisData.mdb")
    6.     Set f = dbs.TableDefs("Shipment").CreateField("Shipment_NextDate", dbDate)
    7.     dbs.TableDefs("Shipment").Fields.Append f
    8.     dbs.Close
    9.     Set dbs = Nothing
    10. End Sub

    -= a peet post =-

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    Brossard, Québec, Canada
    Posts
    241

    Thumbs up Bullseye!

    Thank you very much!

  5. #5
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    your welcome David
    -= a peet post =-

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    Brossard, Québec, Canada
    Posts
    241
    Nice icon you have there by the way!

  7. #7
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    thanks

    u'rs only need a final touch
    -= a peet post =-

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width