I've been going back and forth on whether or not to post a reply......
I'm in agreement with davegri on this.
@Gicu
Originally Posted by
Gicu
<snip> "I have to work harder on this shi...y forum ......
I'm not offended, but I am curious as to why you are still on the forum, if that is the way you truly feel about the forum....
Originally Posted by
cbmorehouse
I tried that and it didn't work.
@cbmorehouse,
maybe you are new to forums and don't understand that a reply like "it didn't work." is not informative. There should be info on what happened, didn't happen, error messages, results, etc. We don't know your skill level with VBA or Access in general. Details from you are important to be able to try and give a valid response.
Originally Posted by
cbmorehouse
No reason for you to be a complete asshole though.
However, bad behavior is NEVER acceptable.
"complete asshole"...really???? You (with 5 posts), insulting the person (with 5,800+ posts) trying to help you is astonishing.
Ever heard the saying "Never bite the foot that stomps your grapes"?
Against my better judgment, I looked at your code and made a couple of changes.
Code:
Private Sub tglYesNo_Click()
Dim sSQL As String
Dim MeFilter As String
'is there a filter applied?
If Len(Me.Filter) > 0 Then
MeFilter = " WHERE " & Me.Filter
Else
MeFilter = vbNullString
End If
sSQL = "UPDATE tblItemDetail SET tblItemDetail.YourFieldName = " & Me.tglYesNo & MeFilter
'Debug.Print sSQL
CurrentDb.Execute sSQL, dbFailOnError
Me.Requery
If Me.tglYesNo Then
Me.tglYesNo.Caption = "Un-Tick All"
Else
Me.tglYesNo.Caption = "Tick All"
End If
End Sub
Another option:
Code:
Private Sub tglYesNo_Click()
Dim sSQL As String
Dim MeFilter As String
MeFilter = Me.Filter
Select Case tglYesNo
Case True
sSQL = "UPDATE tblItemDetail SET tblItemDetail.YourFieldName = TRUE WHERE " & MeFilter
'Debug.Print sSQL
CurrentDb.Execute sSQL, dbFailOnError
Me.tglYesNo.Caption = "Un-Tick All"
Case False
sSQL = "UPDATE tblItemDetail SET tblItemDetail.YourFieldName = FALSE WHERE " & MeFilter
'Debug.Print sSQL
CurrentDb.Execute sSQL, dbFailOnError
Me.Requery
Me.tglYesNo.Caption = "Tick All"
End Select
End Sub
Is "Selection" the name of the field in the table? Don't know because you haven't said anything about the table/fields.....
Replace YourFieldName with the field name that is used to "select" record(s).