473,411 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Last checkbox doesnt want to party

Hi,

I'm a relative newby and have a tricky problem in Access 2002.

I have a continuous form with a check box called "Select". (I now know
I shouldn't have called it that but it's way too late to change now).

I've set up a command button to changes the check box from Yes to No
with the following code:-

Set db = CurrentDb
db.Execute "UPDATE DISTINCTROW Contacts SET [Select] = 0 "
Me.Dirty = False

This manages to change all the check boxes EXCEPT one - it's invariably
the last one that I had previously clicked on. This last one only
becomes cleared when I close and re-open the form. Having scoured the
NG for solutions I saw something similar and hence put in the
Me.Dirty=False bit but that doesn't seem to work.

The open/close routine is irritating to all the users, as when it
re-opens, the form jumps to the first records. We've got something like
2600 records and the pressure is on to find a fix.

Can any one help? Thanks

Caroline

Nov 13 '05 #1
12 1929
1. Save the current record *before* executing the update query statement
(i.e. put the Me.Dirty line first.)

2. Use dbFailOnError in the execute line, so you get to hear about anything
that does not update properly, i.e.:
db.Execute "UPDATE...", dbfailOnError

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<sa*******@yahoo.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Hi,

I'm a relative newby and have a tricky problem in Access 2002.

I have a continuous form with a check box called "Select". (I now know
I shouldn't have called it that but it's way too late to change now).

I've set up a command button to changes the check box from Yes to No
with the following code:-

Set db = CurrentDb
db.Execute "UPDATE DISTINCTROW Contacts SET [Select] = 0 "
Me.Dirty = False

This manages to change all the check boxes EXCEPT one - it's invariably
the last one that I had previously clicked on. This last one only
becomes cleared when I close and re-open the form. Having scoured the
NG for solutions I saw something similar and hence put in the
Me.Dirty=False bit but that doesn't seem to work.

The open/close routine is irritating to all the users, as when it
re-opens, the form jumps to the first records. We've got something like
2600 records and the pressure is on to find a fix.

Can any one help? Thanks

Caroline

Nov 13 '05 #2
> I'm a relative newby and have a tricky problem in Access 2002.

I have a continuous form with a check box called "Select". (I now know
I shouldn't have called it that but it's way too late to change now).

I've set up a command button to changes the check box from Yes to No
with the following code:-

Set db = CurrentDb
db.Execute "UPDATE DISTINCTROW Contacts SET [Select] = 0 "
Me.Dirty = False

This manages to change all the check boxes EXCEPT one - it's invariably
the last one that I had previously clicked on.


The record is locked by the form and will not be updated from the query.
You are saving it (and so clearing the lock) *after* you try the update
query. Move the line one position up and you will be on air.

You can do

db.execute SQLstring, dbfailonerror

to get a trappable error message (in this case: not all records can be
updated--I hope :-) but in your case I think it is sufficient to save
the record from code.

runcommand accmdsaverecord

will do too, just before the db.execute
I still hesitate to suggest dirty=false because it doesn't look to me
like saving. Consider that a personal remark, if it works, why bother?

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html

Nov 13 '05 #3
Good on you Allen, that's made my day! And thanks for the extra tip
too.

All this progress is going to my head and prompts me to ask if there's
an easy way to get such a command to report back the number of records
that are modified.

I could really usefully use such info on some of the other checkboxes
that are on the same continuous form.

Many thanks

Caroline

Allen Browne wrote:
1. Save the current record *before* executing the update query statement
(i.e. put the Me.Dirty line first.)

2. Use dbFailOnError in the execute line, so you get to hear about anything
that does not update properly, i.e.:
db.Execute "UPDATE...", dbfailOnError

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<sa*******@yahoo.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Hi,

I'm a relative newby and have a tricky problem in Access 2002.

I have a continuous form with a check box called "Select". (I now know
I shouldn't have called it that but it's way too late to change now).

I've set up a command button to changes the check box from Yes to No
with the following code:-

Set db = CurrentDb
db.Execute "UPDATE DISTINCTROW Contacts SET [Select] = 0 "
Me.Dirty = False

This manages to change all the check boxes EXCEPT one - it's invariably
the last one that I had previously clicked on. This last one only
becomes cleared when I close and re-open the form. Having scoured the
NG for solutions I saw something similar and hence put in the
Me.Dirty=False bit but that doesn't seem to work.

The open/close routine is irritating to all the users, as when it
re-opens, the form jumps to the first records. We've got something like
2600 records and the pressure is on to find a fix.

Can any one help? Thanks

Caroline


Nov 13 '05 #4
Sure. Examine the RecordsAffected property of the database variable,i.e.:
MsgBox db.RecordsAffected

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<sa*******@yahoo.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Good on you Allen, that's made my day! And thanks for the extra tip
too.

All this progress is going to my head and prompts me to ask if there's
an easy way to get such a command to report back the number of records
that are modified.

I could really usefully use such info on some of the other checkboxes
that are on the same continuous form.

Many thanks

Caroline

Allen Browne wrote:
1. Save the current record *before* executing the update query statement
(i.e. put the Me.Dirty line first.)

2. Use dbFailOnError in the execute line, so you get to hear about
anything
that does not update properly, i.e.:
db.Execute "UPDATE...", dbfailOnError
<sa*******@yahoo.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
> Hi,
>
> I'm a relative newby and have a tricky problem in Access 2002.
>
> I have a continuous form with a check box called "Select". (I now know
> I shouldn't have called it that but it's way too late to change now).
>
> I've set up a command button to changes the check box from Yes to No
> with the following code:-
>
> Set db = CurrentDb
> db.Execute "UPDATE DISTINCTROW Contacts SET [Select] = 0 "
> Me.Dirty = False
>
> This manages to change all the check boxes EXCEPT one - it's invariably
> the last one that I had previously clicked on. This last one only
> becomes cleared when I close and re-open the form. Having scoured the
> NG for solutions I saw something similar and hence put in the
> Me.Dirty=False bit but that doesn't seem to work.
>
> The open/close routine is irritating to all the users, as when it
> re-opens, the form jumps to the first records. We've got something like
> 2600 records and the pressure is on to find a fix.
>
> Can any one help? Thanks
>
> Caroline

Nov 13 '05 #5
why not just requery the form after your code.

ie..

Set db = CurrentDb
db.Execute "UPDATE DISTINCTROW Contacts SET [Select] = 0 "
Me.Requery

Nov 13 '05 #6
Because requery certainly resets the current record to the first in the
set. That is not what she wanted.

SilvrT wrote:
why not just requery the form after your code.

ie..

Set db = CurrentDb
db.Execute "UPDATE DISTINCTROW Contacts SET [Select] = 0 "
Me.Requery


--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html

Nov 13 '05 #7
Bas Cost Budde wrote:
Because requery certainly resets the current record to the first in the
set. That is not what she wanted.

SilvrT wrote:
why not just requery the form after your code.

ie..

Set db = CurrentDb
db.Execute "UPDATE DISTINCTROW Contacts SET [Select] = 0 "
Me.Requery


And a .Requery will clear any Bookmarks so you can't use that to navigate back to the
record. However you could save the unique record identifier and then .Seek or .Find back
to the appropriate record after the .Requery.

--
'---------------
'John Mishefske
'---------------
Nov 13 '05 #8
Regardless, essentially when you close the form and re open it you are
requerying the records anyway. Use some means to position or display
the records the way you want them such as an SQL select statement in
the Recordsource property utilizing an "order by" statement or
something else that will work for you. Personally, I didn't quite "get"
exactly where Caroline wanted to leave the record pointer at.
Set db = CurrentDb
db.Execute "UPDATE DISTINCTROW Contacts SET [Select] = 0 "
Me.Recordsource="select * from Contacts order by <whatever>"
Me.Requery


Also, you can store a Bookmark to a variable and get back to the record
that way without closing the form.
eg.

myVar = Me.Bookmark
Me.Requery
Me.Bookmark = myVar
Only tryin to be of assistance :-)

Nov 13 '05 #9
SilvrT wrote:
Regardless, essentially when you close the form and re open it you are
requerying the records anyway. Use some means to position or display
the records the way you want them such as an SQL select statement in
the Recordsource property utilizing an "order by" statement or
something else that will work for you. Personally, I didn't quite "get"
exactly where Caroline wanted to leave the record pointer at.

Set db = CurrentDb
db.Execute "UPDATE DISTINCTROW Contacts SET [Select] = 0 "
Me.Recordsource="select * from Contacts order by <whatever>"
Me.Requery

Also, you can store a Bookmark to a variable and get back to the record
that way without closing the form.
eg.

myVar = Me.Bookmark
Me.Requery
Me.Bookmark = myVar
Only tryin to be of assistance :-)


I don't think that will work. A .Requery clears bookmarks. From the
on-line help on Bookmark Property:

"Requerying a form invalidates any bookmarks set on records in the form. However, clicking
Refresh on the Records menu doesn't affect bookmarks."

I think the safest method is to store the unique identifier of the record and use that to
get back to the record after the .Requery.

--
'---------------
'John Mishefske
'---------------
Nov 13 '05 #10
worked for me... what can I say?

Nov 13 '05 #11
worked for me... what can I say?

Nov 13 '05 #12
But I do agree with the use of Refresh as well as using the unique
identifier.

Nov 13 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Cheddar | last post by:
I'm back again with another problem. What I want is for the user to click a checkbox and have a list appear. I think the code is almost there but it doesnt seem to be working, grrrr. Can anyone...
3
by: Rich | last post by:
I have a form with 2 check boxes. One of the check boxes is used to specify that the user is a "primary contact." When I check the primary contact box I want a second box for "standard contact"...
2
by: Kekec | last post by:
I have several disabled asp:checkboxes in my table, but when i open this page in Netscape 7, Disabled property is ignored. Offcourse in IE is all perfect! Can someone help me with this one?
0
by: louise raisbeck | last post by:
Hi there, I am databinding a datagrid on the onload with the usual !IsPostBack condition. I have to create some dynamic checkboxes, because i dont know how many i will need until the dataset...
0
by: louise raisbeck | last post by:
Hi there, I am databinding a datagrid on the onload with the usual !IsPostBack condition. I have to create some dynamic checkboxes, because i dont know how many i will need until the dataset...
1
by: evanburen | last post by:
I'm passing the name of a div and the name of checkbox to this function which either hides or displays the div. My problem is this line // var the_box =...
0
by: Jayender | last post by:
Hi , I have placed checkbox in my gridview .. now when i check the chekbox and click anybutton the checkbox becomes unchecked. but when i normally add checkbox in the page it doesnt happen but...
1
by: arun.hallan | last post by:
Hi, I have two columns in a datagrid that are filled with checkboxes. I want one checkbox in a row to be checked when the corresponding checkbox is checked. I've added an OnCheckedChanged...
3
by: Raymond | last post by:
I am having a problem about the dynamic checkbox Private Sub Page_Load Me.NumberOfChkControls = 0 Dim cbCheckBox As New CheckBox cbCheckBox.Text = .Id.ToString cbCheckBox.ID = "ControlID_" +...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.