Forum Home
Press F1
 
Thread ID: 21783 2002-07-03 23:59:00 Access 97, q2 Steve (838) Press F1
Post ID Timestamp Content User
59604 2002-07-03 23:59:00 I have an Access 97 database with 20 check boxes on it. There is a text box that counts the number of "yes" (-1) marks. I'd like the results of this to appear in the underlying database, in a field called [numerator].

Numerator works on the form, but the record source is the calculation: (that is -1*the sum of the values of the 20 check boxes. Clumsy? Maybe, but it works...) But because the record source is the calculation, the result doesn't appear in the Numerator field in the underlying database.

How do I get the result of the calculated field into the database?

Cheers,

Steve
Steve (838)
59605 2002-07-04 10:12:00 For simplicitys sake, the easiest way is to have the form [numerator] field bound to the numerator field in the table, and update the field's value on an event.
For example:
Create a new unbound text field to receive the 'calculation'.
Change the record source for the [numerator] textbox back to the numerator field in the table.

Now we need to get the calculated value to the [numerator] textbox:

For each of the checkboxes, add an event procedure to the 'On click' event:

Private Sub Check2_Click()
Me![Numerator] = Me![CalcTextBox]
End Sub
Now when a checkbox is clicked, the numerator field is updated. More ideally, use a single event procedure attached to a 'save' button or something similiar.

Going further, you could update a table's fields directly in code, without having to transfer data between form controls, but that's another story... :D

Hope this makes sense
wuppo (41)
59606 2002-07-08 22:05:00 Thanks, wuppo, for the two replies. And yes, they both make sense!
Cheers,
Steve
Steve (838)
1