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.
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.
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.
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.
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...
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.