Check box with command button

G

Guest

Checkbox name is count and command button name is Update. When I click the
command button I want the checkbox to = true. I have tried these two things
and both tell me the the form is read only. Can someone please give me the
correct code?

update_on click
me.count = true

update_on click
if me.count = false then
me.count = true
else
me.count = false
end if
 
M

Marshall Barton

Ryan said:
Checkbox name is count and command button name is Update. When I click the
command button I want the checkbox to = true. I have tried these two things
and both tell me the the form is read only. Can someone please give me the
correct code?

update_on click
me.count = true


That code would work if the form was updatable. Is the
form's record source table/query updatable? Have you done
something else to make it readonly? What is the check box's
control source?
 
D

Douglas J. Steele

I'm guessing your form is using a query as its recordsource, and that query
isn't updatable.
 
F

fredg

Checkbox name is count and command button name is Update. When I click the
command button I want the checkbox to = true. I have tried these two things
and both tell me the the form is read only. Can someone please give me the
correct code?

update_on click
me.count = true

update_on click
if me.count = false then
me.count = true
else
me.count = false
end if

If the form is 'Read Only" then you can't make changes.
Set the Form's AllowEdits property to Yes.

Note that opening this form froma an event, using the acFormReadOnly
argument in the OpenForms method, will over-ride the AllowEdits
property. You'll have to check this yourself.

Also, you're batting 2 for 2 in your use of Count and Update as field
names.

Count and Update are both reserved Access/VBA/Jet words and should not
be used as a field name.
For additional reserved words, see the Microsoft KnowledgeBase article
for your version of Access:

109312 'Reserved Words in Microsoft Access' for Access 97
209187 'ACC2000: Reserved Words in Microsoft Access'
286335 'ACC2002: Reserved Words in Microsoft Access'
321266 'ACC2002: Microsoft Jet 4.0 Reserved Words'

For an even more complete list of reserved words, see:
http://www.allenbrowne.com/AppIssueBadWord.html
 

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