Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA coding populating a table from form entries

Status
Not open for further replies.

pmkieffe

Technical User
Jun 12, 2006
32
ID
I have a form set up with command boxes pulling from three different tables. How can I code a command button to populate a new table with each entry combination from the form?

Thanks,
pmkieffe
 
Not sure if this is simply what you mean.

Private Sub cmdPopulate_Click()
Dim rs As DAO.Recordset
Dim cntrl As Access.Control
Set rs = CurrentDb.OpenRecordset("tblNew", dbOpenDynaset)
rs.AddNew
For Each cntrl In Me.Controls
If Not cntrl.Tag = "" Then
rs.Fields(cntrl.Tag) = cntrl.Value
End If
Next cntrl
rs.Update
End Sub


This assumes that you put the name of your field into the tag propery, and that tblnew exists already.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top