Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Go to new record in table

0 views
Skip to first unread message

Del

unread,
Nov 16, 2007, 6:54:00 PM11/16/07
to
I use code to create a table. Then I want to store data in the table from
unbound controls on a form. What code can I use to write this data?

--
Thank you,
Del

John W. Vinson

unread,
Nov 16, 2007, 7:48:19 PM11/16/07
to
On Fri, 16 Nov 2007 15:54:00 -0800, Del <D...@discussions.microsoft.com> wrote:

>I use code to create a table. Then I want to store data in the table from
>unbound controls on a form. What code can I use to write this data?

Open a Recordset based on the table; use the recordset's AddNew method; set
the fields to the desired values.

Dim rs As DAO.Recordset
Set rs = db.OpenRecordset("[tablename]", dbOpenDynaset)
rs.AddNew
rs!ThisField = Me![txtThisField]
rs!ThatField ] = Me![txtThatField]
<etc>
rs.Update
rs.Close
Set rs = Nothing

Why do it the hard way though??? Creating new tables ad hoc is (in my
experience) *very* rarely either necessary or a good idea.

John W. Vinson [MVP]

0 new messages