Update selecting all flaged records bar 1

atrium

Registered User.
Local time
Today, 20:11
Joined
May 13, 2014
Messages
348
I have a screen where the user selects rows by clicking on a tick box. ( e.g. user selects 4 out of 6 rows, I check the Table after this and the flag in turned on in the 4 records selected) I have an update query that changes two fields in each row if the flag is turned on. The update query selects all except 1 (the first one). I also run an update to turn off the flags I check the table after this and the flag is still turned on for that one record???

Can anyone help please
 
Please show us some code.
 
Does the flag's behavior in-program match its behavior on the screen? I.e. do you simultaneously see a flag that should be clear and have a program also detect a flag as set but that should be clear?
 
The code that is supposed to reset the GeneralFlag to false is
UPDATE DocumentLibrary SET DocumentLibrary.ParentFolder = [Forms]![DocumentLibraryFrm]![ToFolderFld], DocumentLibrary.FolderName = [Forms]![DocumentLibraryFrm]![ToFolderFld], DocumentLibrary.GeneralFlag = False
WHERE (((DocumentLibrary.GeneralFlag)=True));

Atrium
 
To The_Doc_Man
One the screen it is ticked (True) if I stop the code, on the table it is ticked (true) As per the example above the four are ticked (true) but only three are changed the last one ticked is the one left and not changed
 
OK, that eliminated an "artifact" (where one shows but the other doesn't). So this is somehow a real event. And you also say that the two text fields are not updated correctly either. This certainly sounds odd.

I think we need more info about the context here. Is this a split front-end/back-end case or a single-file case? If split, is the back-end file an Access file or something like SQL Server, ORACLE, or some other ODBC-enabled server?

If you manually verify that the 1st record of the selected group is still ticked, can you then try to re-run the query and cause the change for that one remaining record?
 
A single file case.
Yes verified that if I go back in and run it again the last one is changed.

Regards
 
1. You have an update query based on flags to select records.
2. When you run the query you get all but one selected record to register the change.
3. When that query is done, both programmatically and visually you can see that one of the records that was flagged was not affected.
4. If you re-run the query then you see the last selected record get affected.

In a stand-alone situation, this makes no sense. But your first post says "I have a screen where the user selects rows " which is an odd way of saying that UNLESS it is a multi-user database and sometimes the user isn't you.

Is there a chance that the database, though a single file, is shared among multiple users?

Because if so, we are looking at a potential record-locking conflict. Please clarify the big picture of how this database is used because in isolation, this shouldn't happen. But if it is shared among users, there is a very strong possibility that it is merely a record-access conflict. So please tell us what is going on with your users.
 
Yes the environment is a multi-user server system. I'm using my development version of the production database and I'm the only user.
Just to reiterate - The process here is to be able to bulk move documents between folders in the clients Document Library.
The first part of the process is to select the From: and To: folders. The system then displays a page with all of the document currently in the From folder to allow the user to indicate which documents are to be moved.
The attached image is a copy of the selection screen where the document have been ticked.
I have discovered that it's the last record that is ticked that doesn't get moved . Even though the fieldmon the record is ticked the following query doesn't seem to recognise it

UPDATE DocumentLibrary SET DocumentLibrary.ParentFolder = [Forms]![DocumentLibraryFrm]![ToFolderFld], DocumentLibrary.FolderName = [Forms]![DocumentLibraryFrm]![ToFolderFld]
WHERE (((DocumentLibrary.GeneralFlag)=True));


NOTE - After ticking the last record I then go and click on the File Description (no other reason other than to move focus from the tick box of the last one ticked) and then press OK to perform the above query it all works.

What do I need to do to programmatically move focus from the last file ticked

Help!!!!
 

Attachments

  • DocSelection.PNG
    DocSelection.PNG
    15.2 KB · Views: 110
Try explicitly saving the record before executing.

If this is multi user what happens if user one ticks 4 records and user 2 ticks 5 records so that 9 records have a true value and user one then executes. Will all 9 records be executed for user ones settings?
You may want to use a multi-select listbox.
 
Thanks every one for your input. moke123 made me think about the state of the file. I closed the form down with save and then performed what I needed to and it works fine now

Thanks again guys:)(y)
 
Glad you got it sorted.

Just bear in mind that if you are using a yes/no field in a table and using it to mark records for some action that there may be another user doing the same thing at the same time. So even though you may be working with different records Access doesnt know that and the first one to execute the action will include both records. Access is just going to update all the records marked true. You should specifically identify your records to be updated thats why I recommend a multiselect listbox.
 

Users who are viewing this thread

Back
Top Bottom