Entering a record fields through independent
There are several ways to enter a record, and the most common is to get through a form bound to a table. Another way to do this is through unrelated fields, ie using a form with fields independent unrelated to the table. To
enter the data we use the 'recordset', ie by a code, which in the case of this example is as follows:
Dim db As Database
Dim rs As RecordsetIf MsgBox ("Would you like to write?" VbYesNoCancel, "Options") = vbYes Then
"By pressing is asked whether to save the record or not, if so the code continues until end
Set db = CurrentDb ()
Set rs = db.OpenRecordset ("Data", dbOpenTable)
'Open the table to insert the data registerrs.AddNew
rs ("name") = Me! INome
rs ("address") = Me! Imorada
rs ("age") = Me! Iidade
rs.Update 'sends the data to the table
rs.Close 'Clear the data and closes the recordset
Set rs = Nothing
Set db = NothingMe.INome = Null 'clears the fields in the form
Me.Imorada = Null
Me.Iidade = Null
MsgBox "Record saved", vbInformation, "Done" 'Display confirmation message
Me.INome.SetFocus' Move the cursor to the first field
Else: Exit Sub
End If
Download: Place Independent






























No comments.