PDA

View Full Version : Solved: Minus A Value From A Record Using VBA



bopo
12-08-2007, 07:11 AM
Hi Everyone

Well basically I have a form, and when a calcution is performed, (using VBA) I want a value e.g. 1 to be minused from a particular field within a record (this record will always be the same) and save that deducation permenantely within the table.

Help appreciated

XLGibbs
12-08-2007, 08:39 AM
When your form calculation executes, have it run and UPDATE statement..

without any more information..hard to give a clean anwer..

Update [Table]
Set [Column] = FormCalculationREsult - 1

bopo
12-08-2007, 08:54 AM
Yeah that sounds like correct, except could I have a WHERE Cause which says WHERE ID = 2 for example? Sorry im quite new to VBA.

Also how would I write this in using VBA?

Thanks for your help

bopo
12-08-2007, 11:08 AM
Ok I managed to figure it out, however I am getting an error with the query saying:

"Run Time Error '3061': Too few paramters. Expected 1.

Below is the query

CurrentDb.Execute "UPDATE AccommodationInformation SET AccommodationInformation.NumberOfRooms = AccommodationInformation.NumberOfRooms - StoreRoomQuantity WHERE AccommodationInformation.AccommodationInfoID = 1"

bopo
12-09-2007, 06:28 AM
EDIT: Got everything working, and just used Exit Sub to ensure the input box isnt repeated :)