PC Review


Reply
Thread Tools Rate Thread

Command Button to Uncheck Checkbox on all records

 
 
Kate
Guest
Posts: n/a
 
      8th Jan 2008
I create a command button to uncheck a checkbox on the form, which works, but
I want it to uncheck the the same checkbox on all records. I am doing this
for the church and am not using access on a regular basis, so I just need the
rest of the code. Thanks for any help.
--
Kate
Just learning to use access
 
Reply With Quote
 
 
 
 
Steve Schapel
Guest
Posts: n/a
 
      8th Jan 2008
Kate,

You will need an Update Query. You can do this in code, which runs on
the Click event of your command button, like this:

CurrentDb.Execute "UPDATE YourTable SET YourYesNoField = 0", dbFailOnError

--
Steve Schapel, Microsoft Access MVP

Kate wrote:
> I create a command button to uncheck a checkbox on the form, which works, but
> I want it to uncheck the the same checkbox on all records. I am doing this
> for the church and am not using access on a regular basis, so I just need the
> rest of the code. Thanks for any help.

 
Reply With Quote
 
Kate
Guest
Posts: n/a
 
      8th Jan 2008
I am geeting an error. My table is named Addresses and my checkbox is named
IndividualReport.
Here is my code:
Private Sub Command239_Click()
If Me.IndividualReport = True Then
Me.IndividualReport = False
End If
'CurrentDb.Execute "UPDATE YourTable SET YourYesNoField = 0", dbFailOnError
CurrentDb.Execute "UPDATE Addresses SET IndividualReport = 0", dbFailOnError
End Sub

I don't know any code.
Thanks

--
Kate
Just learning to use access


"Steve Schapel" wrote:

> Kate,
>
> You will need an Update Query. You can do this in code, which runs on
> the Click event of your command button, like this:
>
> CurrentDb.Execute "UPDATE YourTable SET YourYesNoField = 0", dbFailOnError
>
> --
> Steve Schapel, Microsoft Access MVP
>
> Kate wrote:
> > I create a command button to uncheck a checkbox on the form, which works, but
> > I want it to uncheck the the same checkbox on all records. I am doing this
> > for the church and am not using access on a regular basis, so I just need the
> > rest of the code. Thanks for any help.

>

 
Reply With Quote
 
Steve Schapel
Guest
Posts: n/a
 
      8th Jan 2008
Kate,

Thanks for letting us know the names of your table and field, that helps
a lot. However, I don't know what the error message says.

--
Steve Schapel, Microsoft Access MVP

Kate wrote:
> I am geeting an error. My table is named Addresses and my checkbox is named
> IndividualReport.
> Here is my code:
> Private Sub Command239_Click()
> If Me.IndividualReport = True Then
> Me.IndividualReport = False
> End If
> 'CurrentDb.Execute "UPDATE YourTable SET YourYesNoField = 0", dbFailOnError
> CurrentDb.Execute "UPDATE Addresses SET IndividualReport = 0", dbFailOnError
> End Sub
>
> I don't know any code.
> Thanks
>

 
Reply With Quote
 
Kate
Guest
Posts: n/a
 
      8th Jan 2008
When I click on command button I Get This Error.

Run-Time Error 3061
Too few parameters
Expected 1

Thanks for helping.
--
Kate
Just learning to use access


"Steve Schapel" wrote:

> Kate,
>
> Thanks for letting us know the names of your table and field, that helps
> a lot. However, I don't know what the error message says.
>
> --
> Steve Schapel, Microsoft Access MVP
>
> Kate wrote:
> > I am geeting an error. My table is named Addresses and my checkbox is named
> > IndividualReport.
> > Here is my code:
> > Private Sub Command239_Click()
> > If Me.IndividualReport = True Then
> > Me.IndividualReport = False
> > End If
> > 'CurrentDb.Execute "UPDATE YourTable SET YourYesNoField = 0", dbFailOnError
> > CurrentDb.Execute "UPDATE Addresses SET IndividualReport = 0", dbFailOnError
> > End Sub
> >
> > I don't know any code.
> > Thanks
> >

>

 
Reply With Quote
 
Steve Schapel
Guest
Posts: n/a
 
      8th Jan 2008
Thanks Kate. Well, you can remove the original code. So just leave the
one line of code:
Private Sub Command239_Click()
CurrentDb.Execute "UPDATE Addresses SET IndividualReport = 0",
dbFailOnError
End Sub

And then, can you please double check and make quite sure that the name
of the field in the Addresses table is IndividualReport and that you
have it 100% correctly spelt in the code, and the same for the name of
the table.

--
Steve Schapel, Microsoft Access MVP

Kate wrote:
> When I click on command button I Get This Error.
>
> Run-Time Error 3061
> Too few parameters
> Expected 1
>
> Thanks for helping.

 
Reply With Quote
 
Kate
Guest
Posts: n/a
 
      9th Jan 2008
Thanks Steve,
It is working now. There was a space between Individual & Report ,so I put
it in brackets. It is a little slow updating 30 second or so, but a lot
faster than manually unchecking all of them. One more question if you don't
mind. I have a checkbox for single & one for married. I would like to make
sure if one is checked the other can't be. Would something like
If Single=true then Married=false
Should you use true or -1 or false for 0
Thanks again.


--
Kate
Just learning to use access


"Steve Schapel" wrote:

> Thanks Kate. Well, you can remove the original code. So just leave the
> one line of code:
> Private Sub Command239_Click()
> CurrentDb.Execute "UPDATE Addresses SET IndividualReport = 0",
> dbFailOnError
> End Sub
>
> And then, can you please double check and make quite sure that the name
> of the field in the Addresses table is IndividualReport and that you
> have it 100% correctly spelt in the code, and the same for the name of
> the table.
>
> --
> Steve Schapel, Microsoft Access MVP
>
> Kate wrote:
> > When I click on command button I Get This Error.
> >
> > Run-Time Error 3061
> > Too few parameters
> > Expected 1
> >
> > Thanks for helping.

>

 
Reply With Quote
 
Steve Schapel
Guest
Posts: n/a
 
      10th Jan 2008
Kate,

I can't imagine why the update is so slow. Even if you had millions of
records and you running the database on a very old machine with
insufficient memory, 30 seconds is outside the realms of fantasy.

As for the Married/Single, basically this is a design flaw. Are you
able to consider a change to your table/form structure? You should just
have one field for Marital Status.

--
Steve Schapel, Microsoft Access MVP

Kate wrote:
> Thanks Steve,
> It is working now. There was a space between Individual & Report ,so I put
> it in brackets. It is a little slow updating 30 second or so, but a lot
> faster than manually unchecking all of them. One more question if you don't
> mind. I have a checkbox for single & one for married. I would like to make
> sure if one is checked the other can't be. Would something like
> If Single=true then Married=false
> Should you use true or -1 or false for 0
> Thanks again.
>
>

 
Reply With Quote
 
Kate
Guest
Posts: n/a
 
      10th Jan 2008
I am running it on a P4 2.4 with 1 gig Memory. There are less than 200
records in it. I have realized now I should have used a group with option
buttons, but I am querying the married checkbox for a mail merge. Here is my
query: Married is the checkbox. What I want is to put an & sign between
firstname & spoure if married.
This works:
Name: IIf([Married]=-1,[FirstName] & " & " & [SpouseName],[FirstName])

I tried this it doesn't work.
Name1: IIf([SpouseName]=Null,[FirstName],[FirstName] & " & " & [SpouseName])
This puts an & sign after the single and married person.

Like I said before I don't know alot about seting up a database correctly.
I am just trying to help out the church.

Thanks again for your replys.
--
Kate
Just learning to use access


"Steve Schapel" wrote:

> Kate,
>
> I can't imagine why the update is so slow. Even if you had millions of
> records and you running the database on a very old machine with
> insufficient memory, 30 seconds is outside the realms of fantasy.
>
> As for the Married/Single, basically this is a design flaw. Are you
> able to consider a change to your table/form structure? You should just
> have one field for Marital Status.
>
> --
> Steve Schapel, Microsoft Access MVP
>
> Kate wrote:
> > Thanks Steve,
> > It is working now. There was a space between Individual & Report ,so I put
> > it in brackets. It is a little slow updating 30 second or so, but a lot
> > faster than manually unchecking all of them. One more question if you don't
> > mind. I have a checkbox for single & one for married. I would like to make
> > sure if one is checked the other can't be. Would something like
> > If Single=true then Married=false
> > Should you use true or -1 or false for 0
> > Thanks again.
> >
> >

>

 
Reply With Quote
 
Steve Schapel
Guest
Posts: n/a
 
      11th Jan 2008
Kate,

No worries, I'm not expecting you to be an expert. :-) Just wondering
whether you could change it, that's all.

The amount of time a line of code such as we discussed
CurrentDb.Execute... would take to run on your computer would be
measured in microseconds - it would be so quick you couldn't detect it.
So there must be something else causing this 30 second whatever it is.

"[SpouseName]=Null" does not compute. The syntax should be:
IIf([SpouseName] Is Null, ...
or:
IIf(IsNull([SposeName]), ...

Using the existence of data in SpouseName as the test would be more
reliable, and therefore the value of the Married and Single fields
becomes irrelevant, right?

Another way to write in might be like this:
Name1: [FirstName] & IIf(IsNull([SpouseName]),""," & " & [SpouseName])

Here's how I would do it myself, neater but perhaps less inuitive:
Name1: [FirstName] & " & "+[SpouseName]

By the way, as an aside, 'name' is a Reserved Word (i.e. has a special
meaning) in Access, and as such should not be used as the name of a
field or control.

--
Steve Schapel, Microsoft Access MVP

Kate wrote:
> I am running it on a P4 2.4 with 1 gig Memory. There are less than 200
> records in it. I have realized now I should have used a group with option
> buttons, but I am querying the married checkbox for a mail merge. Here is my
> query: Married is the checkbox. What I want is to put an & sign between
> firstname & spoure if married.
> This works:
> Name: IIf([Married]=-1,[FirstName] & " & " & [SpouseName],[FirstName])
>
> I tried this it doesn't work.
> Name1: IIf([SpouseName]=Null,[FirstName],[FirstName] & " & " & [SpouseName])
> This puts an & sign after the single and married person.
>
> Like I said before I don't know alot about seting up a database correctly.
> I am just trying to help out the church.
>
> Thanks again for your replys.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Command Button to Check Checkbox Kate Microsoft Access 5 14th Jan 2008 07:19 AM
Command Button to Check Checkbox yons Microsoft Access 1 14th Jan 2008 05:39 AM
How to have Checkbox A uncheck with checked Checkbox B =?Utf-8?B?VGV4YXMgQWdnaWU=?= Microsoft Excel Misc 3 20th Jul 2007 10:58 PM
Click checkbox with command button =?Utf-8?B?Unlhbg==?= Microsoft Access Form Coding 1 6th Jun 2007 08:05 PM
How do I make this query updatable (I want to be able to scroll the records and check/uncheck one field/checkbox)? Jeff Microsoft Access Queries 1 19th Aug 2004 12:02 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:49 PM.