G
gatarossi
Dear all,
I have a form with unbound fields and I'm trying to update these
fields in my table. I really want that these fields are unbound!!!
My form/subform is like this:
Form
profit_center: administrative
date: 01/01/07
Subform
expenses_code value
salary 100
equipment 20
taxes 0
others costs 50
I need a code that first search the combination profit_center,
expenses_code and date in the table, if this combination already
exist, change the value of this combination; if it not exist, to
include the value and this combination, and if the user put 0, to
exclude the combination.
For example: position of my table before put these information above:
expenses_code profit_center date value
salary administrative 01/01/07 80
taxes administrative 01/01/07 150
position of my table after put these information above:
expenses_code profit_center date value
salary administrative 01/01/07 100
equipment administrative 01/01/07 20
others cost administrative 01/01/07 50
I made this code, but it doesn't work - it's only to show what I did.
Private Sub values_AfterUpdate()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("expenses")
rs.AddNew
rs.Fields("profit_center") = "profit_center"
rs.Fields("date") = "date"
rs.Fields("expenses_code") = "expenses_code"
rs.Fields("value") = "value"
rs.Update
rs.Close
db.Close
End Sub
Thanks,
André.
I have a form with unbound fields and I'm trying to update these
fields in my table. I really want that these fields are unbound!!!
My form/subform is like this:
Form
profit_center: administrative
date: 01/01/07
Subform
expenses_code value
salary 100
equipment 20
taxes 0
others costs 50
I need a code that first search the combination profit_center,
expenses_code and date in the table, if this combination already
exist, change the value of this combination; if it not exist, to
include the value and this combination, and if the user put 0, to
exclude the combination.
For example: position of my table before put these information above:
expenses_code profit_center date value
salary administrative 01/01/07 80
taxes administrative 01/01/07 150
position of my table after put these information above:
expenses_code profit_center date value
salary administrative 01/01/07 100
equipment administrative 01/01/07 20
others cost administrative 01/01/07 50
I made this code, but it doesn't work - it's only to show what I did.
Private Sub values_AfterUpdate()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("expenses")
rs.AddNew
rs.Fields("profit_center") = "profit_center"
rs.Fields("date") = "date"
rs.Fields("expenses_code") = "expenses_code"
rs.Fields("value") = "value"
rs.Update
rs.Close
db.Close
End Sub
Thanks,
André.