Go to new record in table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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]
 
Back
Top