Change value of checkbox at runtime (using VBA)

F

febad

Hello,

I will like to change the value of a check box at runtime. I have a
database with a field "multiple_print_select", which stores a value of
"1" when it is checked so that the record can be printed.

This allows only the records selected to be printed, but wen another
set of records are selected again, the previous selection are still
true, so the records are reprinted which I need to prevent.

So, I'm thinking of changing the value of the checkbox at runtime: For
instance, a VBA code that will set the value of the checkbox to "0" on
closing the report or a better way of doing this.

You help will be highly appreciated.

Regards,
febad
 
M

Maurice

Why not create an update query which you can run when closing the form?
Create the query which set's the values to 0. In the close event of the form
run the query.
 
F

febad

Why not create an update query which you can run when closing the form?
Create the query which set's the values to 0. In the close event of the form
run the query.

How do i create an update query please?

From the switch board, when a botton is clicked, a form opens where
one can search for the records to print. a checkbox object (named
"multiple_cform_select") is checked for records to be printed. The
report is based on a table (named "nscos_db") with the condition that
it should display only records with the value of the checkbox set to
"Yes".

Where is the best place to place this function. because before the
value is cleared from "Yes" to "No"(to avoid repeated print), the
report should have been printed.

thanks, febad
 
M

Maurice

You should check which recordset is being used for setting the checks. Use
that in a new query.

Drag the check field to the grid and change the query to update (look for
type of query in the querymenu).

In the querygrid set updatefield to [tablename].[checkfield]=0
In the criteriafield type 1. This will update all the fields to 0 which are
set to 1

Save the query.

Now place the following statement in the Report_close

Private sub Report_close()
currentdb.execute "query"
end sub

where "query" is the name of your newly created query...

hth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top