Changing value in a table

  • Thread starter Thread starter Galsaba
  • Start date Start date
G

Galsaba

I have the following tables: tanent, invoice.
I have the following forms: tanent, invoice
They are linked.
I have a field in the table "tanent" called "Balance.

I made a botton on the form "invoice", on click part of the following script
will be performed:
....
Dim NewBalance As Variant
Me![New Balance] = Me![Due Ammount] - Me![Ammount paid] ' line 1
NewBalance = Me![Due Ammount] - Me![Ammount paid] ' line 2
tanent!Balance = NewBalance 'line
3
....
line 1 and 2 work ok, but when I add line 3, and click on the button
I have the message "Object Requires".

The purpose of the button is to update the field "New Balance" on the form
"invoice" (this works), and to update the field "Balance" on the table
"Tanent" (which does not work, and gives me the message "Object Required"

Any ideas what's wrong?

Thanks,

Joe
 
Thanks, but I have two problems with this:
1. The form "Tanent" will not be changed, unless I open it. If I dont open form
"Tanent" I got a message "cannot find form Tanent"
2. I want to change the value directly in the Table "Tanent" without openeing
th eform "Tanent".
Thanks
Joe
 
To add a new record to a table, or (as in your case) update a field in a
table, you simply execute an action query. In your case, you want to do it
from a form, so you can use to the NewBalance control to supply the value
you want to store.

CurrentDb.Execute "UPDATE Tanent SET Balance = " & Me!NewBalance,
dbFailOnError

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 
Back
Top