Can I "Tick" (Select) records and batch update them?

there isn't an example to select all - you will need to write your own

regret I do not have the time for it at the moment - you might want to look at the example code provided by arnel as a way to do this
 
there isn't an example to select all - you will need to write your own

regret I do not have the time for it at the moment - you might want to look at the example code provided by arnel as a way to do this

I see, thank you very much your example helped a lot, I apologize for asking too much as I admit I am unable to write codes by myself. I think Sir Arnel's code is for subforms though, not the continuous form like yours that I already built.
 
give it a go - it's the only way to learn
 
CJ_London: umm, before your last post, I went about creating a code snippet for the OP and came back to see your last post. Hope you don't mind if I feed a self-proclaimed novice this time seeing as how I have it.
MackBear: If you're on about how to select all in the sample db form, then add a button and this code for its click event (this is just a quick and dirty way to do it because it just calls an existing sub to do the selecting - there are probably better ways)
Code:
Dim rs As DAO.Recordset

If Me.cmdSelectAll.Caption = "Deselect All" Then
  Me.cmdSelectAll.Caption = "Select All"
  SelectedList = ""
  Exit Sub
End If

 Set rs = Me.Recordset
If Not (rs.BOF And rs.EOF) Then
  rs.MoveFirst
  Do While Not rs.EOF
    Select_Click
    rs.MoveNext
  Loop
  Me.cmdSelectAll.Caption = "Deselect All"
  DoCmd.GoToRecord , , acGoTo, 1

  End If
In the sample db, this causes some screen flicker and alters the sort for some reason, but I'm out of time for the evening to figure out why.
EDIT - quickly realized it's not altering the sort; my list scrolls just enough to move appx the 7th record to the top. You could add DoCmd.GoToRecord , , acGoTo, 1 as edited.
 
Last edited by a moderator:
suggest looping through the recordsetclone rather than the recordset?
Could you explain what you had in mind? The control you have set the source to equal "Select" isn't part of the form's recordset, right? Thus it wouldn't be part of the clone either so how to affect selection with the pipe and ID expression?

I admit I was after a quick and dirty solution because at that point, it wasn't clear to me if the OP's request applied to your form or not.
 
if selecting or deselecting all, it doesn't matter

to deselect all, simple set the selectedlist=""

to select all

Code:
selectedlist=""
with me.recordsetclone
    .movefirst
    while not .eof
        selectedlist=selectedlist & me.ID & "|"
        .movenext
    wend
end with

I don't have the db in front of me right now - but that would be the gist of it
 
attachment.php


Any reason to not use a multi-select listbox?
Your example looks like it was made for one.
 
CJ_London: umm, before your last post, I went about creating a code snippet for the OP and came back to see your last post. Hope you don't mind if I feed a self-proclaimed novice this time seeing as how I have it.
MackBear: If you're on about how to select all in the sample db form, then add a button and this code for its click event (this is just a quick and dirty way to do it because it just calls an existing sub to do the selecting - there are probably better ways)
Code:
Dim rs As DAO.Recordset

If Me.cmdSelectAll.Caption = "Deselect All" Then
  Me.cmdSelectAll.Caption = "Select All"
  SelectedList = ""
  Exit Sub
End If

 Set rs = Me.Recordset
If Not (rs.BOF And rs.EOF) Then
  rs.MoveFirst
  Do While Not rs.EOF
    Select_Click
    rs.MoveNext
  Loop
  Me.cmdSelectAll.Caption = "Deselect All"
  DoCmd.GoToRecord , , acGoTo, 1

  End If
In the sample db, this causes some screen flicker and alters the sort for some reason, but I'm out of time for the evening to figure out why.
EDIT - quickly realized it's not altering the sort; my list scrolls just enough to move appx the 7th record to the top. You could add DoCmd.GoToRecord , , acGoTo, 1 as edited.

Thank you very much for this, I really appreciate it, It did not flicker on my end, thanks for feeding the hungry... hehehehe :):):)
 
attachment.php


Any reason to not use a multi-select listbox?
Your example looks like it was made for one.

Hello, thanks for the suggestion, I will try this on another time as I have already built mine like the example CJ_London has provided. I was laughing at the Me.Dirty=True though... :D:D:D
 
Not a big deal, but generally any time you Set something (as in Set rs = ) you should Set it to Nothing wherever the code ends/exits. I forgot. You can find debate on this topic, as in should do/must do/doesn't matter. I do it because I consider it to be a good programming and there is no down side to it - regardless of anyone else's opinion on whether or not it's necessary.
 

Users who are viewing this thread

Back
Top Bottom