Clear form check box with command button

alex91

New member
Local time
Today, 12:55
Joined
Oct 16, 2008
Messages
9
Untitled-1.jpg


As you can see above, i have a form, with the subform which is the table 'Members'
The field 'printw' is the field i want to clear (un tick all the boxes) using command button 4,
but just dont know how or what VBA/macro to use.
Many Thanks
Alex
 
Since you want to clear the field for all the records, a quick suggestion would be to first set up an update query that will update the field to 0. Then set up the command button to execute the query (the command button wizard can walk you through this).

-dK
 
What a legend, didnt even know about this funtion.
Now will be using it all the time
Cheers Ears
Alex
 
Good to go. =]

As an added bonus, in case you have warnings set on through the database properties and seeing the message "You are about to update X records. Are you sure ..."

You can temporarily turn this off. Before the code line that runs the query (DoCmd.....) use the line

Code:
DoCmd.SetWarnings False

then execute the query and then turn them back on by ...

Code:
DoCmd.SetWarnings True


-dK
 
Good to go. =]

As an added bonus, in case you have warnings set on through the database properties and seeing the message "You are about to update X records. Are you sure ..."

You can temporarily turn this off. Before the code line that runs the query (DoCmd.....) use the line

Code:
DoCmd.SetWarnings False

then execute the query and then turn them back on by ...

Code:
DoCmd.SetWarnings True


-dK

And I would suggest NOT doing that. But instead use

CurrentDb.Execute "YourQueryNameHere", dbFailOnError

as it doesn't require the warnings to be turned off.
 
Oh yeah?

Never heard of that. There ya go alex91, learn something new everyday. :D

Bob, I THINK understand why not to do it the way I expressed - I never wanted to turn it off indefinitely for error feedback in other areas of the application but just to supress those messages I knew would occur but miss if there was any error.

I know it seems intuitive, but I am going to ask to make sure ...
does using: CurrentDb.Execute "YourQueryNameHere", dbFailOnError
only notify if the update does not occur, but supress the normal message?

-dK
 
Oh yeah?

Never heard of that. There ya go alex91, learn something new everyday. :D

Bob, I THINK understand why not to do it the way I expressed - I never wanted to turn it off indefinitely for error feedback in other areas of the application but just to supress those messages I knew would occur but miss if there was any error.

I know it seems intuitive, but I am going to ask to make sure ...
does using: CurrentDb.Execute "YourQueryNameHere", dbFailOnError
only notify if the update does not occur, but supress the normal message?

-dK
It does not give a message that you are about to do XXX and do you want to do it. But it also doesn't give you a message if it doesn't do anything.

Also, if you do choose to use the DoCmd.SetWarnings then you should also always have an error handler in that procedure that resets them as the first line in the error handler so you don't turn them off totally, and accidentally, should something generate an error before you get them turned back on.
 

Users who are viewing this thread

Back
Top Bottom