Today’s guest author is Justin Farrell,
Microsoft Office 2007 Standard, author of the Access 2007 tutorial This is a useful trick which gives the Access Developer additional flexibility when working with forms and data. It uses Access VBA and DAO. Once the user enters data into the unbound textbox (txtBox) and clicks the Send Data To Table button,
Office Standard, Access opens a recordset based on the tblTest table. The txtBox data is then stored in a variable called varTextData and then added to the rst recordset. The recordset is updated and the txtBox control is reset ready for new data to be entered. The result is an unbound form that interacts with a database table. Private Sub cmdSend_Click() Dim db As DAO.DatabaseDim rst As DAO.RecordsetDim varTextData As String varTextData = txtBox Set db = CurrentDb Set rst = db.OpenRecordset("tblTest",
Office 2010 Standard, dbOpenDynaset) rst.AddNew rst,
Microsoft Office 2010 Key!fldTest = varTextData rst.Update rst.Close db.Close Me,
Microsoft Office 2007 Ultimate!txtBox = ""End Sub Justin’s supplied a sample database that illustrates this technique. Send your Power Tips to Mike & Chris at accpower@microsoft.com. <div