Hi
I'm trying to do something that I guess should be simple.
I want the user to type information into a few fields, on an unbound form, and then click on a "POST" command button which adds 2 new records to a table automatically, using the data entered (One new record will do for now). I don't want the table to be seen.
As a trial, I have the following code, in the OnClick event of the command button, simply entering text ("CT") into one of the fields, and then hopefully adding a record in the table, , but nothing happens. Have I coded something wrongly or am I approaching this the wrong way? Do I have the worry about the exact name of the database?
Would appreciate expert help.
Terry
Code:
Private Sub cmdSAVETRANS_Click()
Dim dbEA As DAO.Database
Dim rcdTRANS As DAO.Recordset
Set dbEA = CurrentDb
Set rcdTRANS = dbEA.OpenRecordSet("tblTRANSACTIONS")
rcdTRANS.AddNew
rcdTRANS![TRTYPE] = "CT"
rcdTRANS.Update
End Sub
I'm trying to do something that I guess should be simple.
I want the user to type information into a few fields, on an unbound form, and then click on a "POST" command button which adds 2 new records to a table automatically, using the data entered (One new record will do for now). I don't want the table to be seen.
As a trial, I have the following code, in the OnClick event of the command button, simply entering text ("CT") into one of the fields, and then hopefully adding a record in the table, , but nothing happens. Have I coded something wrongly or am I approaching this the wrong way? Do I have the worry about the exact name of the database?
Would appreciate expert help.
Terry
Code:
Private Sub cmdSAVETRANS_Click()
Dim dbEA As DAO.Database
Dim rcdTRANS As DAO.Recordset
Set dbEA = CurrentDb
Set rcdTRANS = dbEA.OpenRecordSet("tblTRANSACTIONS")
rcdTRANS.AddNew
rcdTRANS![TRTYPE] = "CT"
rcdTRANS.Update
End Sub