By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,611 Members | 1,468 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,611 IT Pros & Developers. It's quick & easy.

Selecting & adding records

P: 1
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.
Nov 28 '11 #1
Share this Question
Share on Google+
6 Replies


NeoPa
Expert Mod 15k+
P: 31,712
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.
Nov 28 '11 #2

TheSmileyCoder
Expert Mod 100+
P: 2,321
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:
Expand|Select|Wrap|Line Numbers
  1. 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.
Nov 28 '11 #3

NeoPa
Expert Mod 15k+
P: 31,712
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.
Nov 28 '11 #4

100+
P: 759
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
Expand|Select|Wrap|Line Numbers
  1. 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 ?
Nov 29 '11 #5

TheSmileyCoder
Expert Mod 100+
P: 2,321
@Mihail

Setting Me.Dirty=False will cause the record to be saved. As far as I know it is equivalent to DoCmd.RunCommand 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.
Nov 29 '11 #6

NeoPa
Expert Mod 15k+
P: 31,712
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.
Nov 29 '11 #7

Post your reply

Sign in to post your reply or Sign up for a free account.