Results 1 to 2 of 2

Thread: HOw to add fields to a Access Table

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Location
    Palmerston North, New Zealand
    Posts
    3

    Question

    I am trying to add a new field, from VB, to an exsiting Access Table.

    When I try with a text box, which is linked to the Table, any changes I make to the text box is stored in the table, without any problems! So far so good.

    But when i try to add a new field (without an object), just using the code, like:

    DatAutoSensor.Recordset.AddNew
    DatAutoSensor.Recordset!SensorID = strSensorID
    DatAutoSensor.Recordset!DateTime = strDate
    DatAutoSensor.Recordset.Update
    DatAutoSensor.Recordset.MoveFirst

    ...where "strSensorID" abd "strDate" are dynamically created variables (not from any VB Object) and "SensorID" and "DateTime" are fields in the Table...it doesn't work. The Table isn't updated!! why is this? How am I supposed to achieve this?

  2. #2
    Addicted Member
    Join Date
    Sep 2000
    Posts
    219
    You will have to use the Fields collection of the TableDef object.

    Click the link below for more info.

    http://msdn.microsoft.com/library/of...cobjFieldX.htm

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