Writing Text boxes to records

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

Guest

I am fairly new to VB and am trying to use a button to write the contents of
two unbound text boxes to a table.

The steps I think it needs to follow are
Open table
write Contents of textbox1 to table.field
write contents of textbox2 to table field2
close table.

I don't know any of the syntax for this and can not find the right on under
the DoCmd section.

Help please.
 
I am fairly new to VB and am trying to use a button to write the contents of
two unbound text boxes to a table.

VB? or Access VBA? They're not the same.
The steps I think it needs to follow are
Open table
write Contents of textbox1 to table.field
write contents of textbox2 to table field2
close table.

I don't know any of the syntax for this and can not find the right on under
the DoCmd section.

You'll need to open a Recordset based on the table, use the AddNew
method, and write the data. This is VBA code, assuming that the code
is in an event on an Access Form.

Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("table", dbOpenDynaset)
rs.AddNew
Rs!field = Me!textbox1
Rs!Field2 = Me!textbox2
rs.Update
rs.Close
Set rs = Nothing

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Back
Top