View Full Version : Access 97, q2

04-07-2002, 11:59 AM
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?



04-07-2002, 10:12 PM
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

09-07-2002, 10:05 AM
Thanks, wuppo, for the two replies. And yes, they both make sense!