"news.btinternet.com" <te*****@btinternet.com> wrote in message
news:bu**********@sparta.btinternet.com...
I have a very simple database. I have information in a form that I would
like to write to a table using some code. The table is called tblTest. The
field I would like to write to is called Date. The data which I would like
to write is Date(). Please can someone help me with this simple code?
Many Thanks,
John
Normally, there would be no point writing code for this sort of thing. If
your form is bound to the table, then you can simply edit the data using the
form and if you needed, for example, today's date automatically entered in a
record then you could use the Date() function as the default value.
If you are certain you need (or want) to write code, then the first thing to
consider is where to write it - that is, when should your code run. You
might want it to run when the form first opens or when a new record is
started or when the user presses a button. Basically, if your form is bound
to a table then you could simply write:
Me!AnyDate = Date()
Where AnyDate is the name of the field. I would not use reserved words
(Date, Name, etc) for field names.
If your form is not bound, or you wanted to update a record other than the
current one then we would need to know which is the primary key so we know
which row to update. In other words give further details about the
structure of tblTest.
Fletcher