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?
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.