>I have a StartDate and EndDate field (in a table) for a project. I would
>like to take the year out of the dates and have that go into the field
[quoted text clipped - 7 lines]
>
>The first part works, but not the second. Thanks.
Thanks. Is there any way that you can use VBA to directly update a table.
For instance, at the end of a series of computations done in code, is there a
direct way to add that final value to a table?
> Assuming Mytable is a correctly defined recordset, the correct syntax is
> MyTable!StartYear = SY. However, I suggest you do this with an update query,
[quoted text clipped - 15 lines]
> >
> >The first part works, but not the second. Thanks.
kingston - 16 Nov 2006 20:30 GMT
Yes, there are many ways to do this depending on the context. For example,
you can create a recordset object and set the field like: Recordset!
Field=Value; look up Recordset Property in Help for examples. Or if you're
doing this in a form, include the field as a control and set the control
value: Me.Control=Value. Or you can formulate an SQL statement to update 1
record in the table and run it.
>Thanks. Is there any way that you can use VBA to directly update a table.
>For instance, at the end of a series of computations done in code, is there a
[quoted text clipped - 5 lines]
>> >
>> >The first part works, but not the second. Thanks.
JonWayn - 17 Nov 2006 01:54 GMT
Here's an example:
Dim MyTable As Recordset, MyDb As Database
Dim Var1 As String
Set MyDb = CurrentDb
Set MyTable = MyDb.OpenRecordset("SomeTableName")
With MyTable
.AddNew
!Field1 = Var1
.Update
End With
> Thanks. Is there any way that you can use VBA to directly update a table.
> For instance, at the end of a series of computations done in code, is there a
[quoted text clipped - 19 lines]
> > >
> > >The first part works, but not the second. Thanks.