Selecting & adding records

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SCmajor
    New Member
    • Nov 2011
    • 1

    Selecting & adding records

    I'm developing a database in access 2003 that will allow users to select several records via a toggle button on a continuous form and then hit a button on the same form that opens a query that appends the selected records to another table. The problem is that all the selected records get appended to the table accept for the one that has focus. I have to hit the button again to get all of the selected records.I also have all of the warnings turned off. I'm not quite sure if that makes a difference.What is the best way around this problem.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32656

    #2
    Although your question is not very well formed, it does appear that your confusion is related to Why Values in Unbound Form Controls do not Persist. If that helps then fine, otherwise you'll need to explain your situation properly before requesting help.

    Comment

    • TheSmileyCoder
      Recognized Expert Moderator Top Contributor
      • Dec 2009
      • 2322

      #3
      My guess is that the last record you clicked on (The one in focus) is still DIRTY(I.e, the change is not saved.) A quick fix to this, is to add to your code a forced save:
      Code:
      Me.Dirty=False
      This should go in the code for you button, before you run your query to transfer records.

      I hope this is what you need, otherwise you need to try to explain your situation and setup better (toggle button bound or unbound for instance) as well as any code used.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32656

        #4
        You're probably right there Smiley. I misread "The problem is that all the selected records get appended to the table accept for the one that has focus." as "... all the records ...".

        This indicates the control is almost certainly bound, as it would have to be for this to work at all.

        Comment

        • Mihail
          Contributor
          • Apr 2011
          • 759

          #5
          Hello !

          I don't know how work DIRTY command.
          If you set DIRTY to false that automatically save (update) the record(s) ?

          Just another idea is to place this code
          Code:
          DoCmd.RunCommand acCmdSaveRecord
          under On Click event of your toggle button.

          SCmajor !
          I have a perplexity.
          I understand that the toggle button is linked to a Yes/No field.
          Saying you select 300 records (turn the Yes/No field to Yes) you will need another 300 clicks to deselect this records, isn't it ?
          How you handle that ?

          Comment

          • TheSmileyCoder
            Recognized Expert Moderator Top Contributor
            • Dec 2009
            • 2322

            #6
            @Mihail

            Setting Me.Dirty=False will cause the record to be saved. As far as I know it is equivalent to DoCmd.RunComman d acCmdSaveRecord, but I am not 100% sure if they are exactly identical. I personally prefer and always use the first method.

            Instead of clicking 300 times, I assume he runs an update query setting the value of the field to false.

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32656

              #7
              Very interesting point Smiley. For the record, I believe the two commands are synonymous, but I can't be 100% sure.

              Personally, I prefer the latter method as it is very clear about what the code is doing. The former is an approach I don't believe should even be there. It's counter-intuitive and can lead to confusions. That's just my personal opinion of course. Not agreeing with me should not be considered wrong - just a different approach.

              Comment

              Working...