George-Bowyer
Registered User.
- Local time
- Today, 12:46
- Joined
- Dec 21, 2012
- Messages
- 178
I have a db where Users can Mark contacts for later reference by clicking a chkMark checkbox on the frmContacts (and in various other ways).
When the checkbox is ticked it creates a new unique dual key record in tblMarkedPeople with fldPeopleID and fldUserID. When the checkbox is unchecked, that record in tblMarkedRecord is deleted.
I have a "continuous forms" form based on qryPeople, where I want to highlight records that are marked.
I have done this by putting the following code in Detail_Paint:
(I cannot remember why I went for "If Not DCount = 0" rather than "If Dcount = 1", but I suppose I probably thought I had a reason at the time...)
This does what I want. The marked records are greyed out.
However, when I apply a filter to the form, I get this:
Even more weirdly, I have to click the [End] button numerous times (sometimes more than 20) to end the debug. (I am pretty sure that the number of clicks depends on the number of records returned by the filter, but it's not as simple as 1 click per record or anything like that.
I regret to have to say that I apply the filter with a Macro in the after update action of txtSearch (which is in the form header).
I filched this macro from somewhere before I knew how to write any VBA and have never got around to coding it instead. I have no idea whether this would make any difference to this particular error, which seems to make the Detail_Paint code "lose sight" of [PeopleID].
Can anyone please explain why the filter causes this problem and how to fix or get around it?
Many thanks,
George
When the checkbox is ticked it creates a new unique dual key record in tblMarkedPeople with fldPeopleID and fldUserID. When the checkbox is unchecked, that record in tblMarkedRecord is deleted.
I have a "continuous forms" form based on qryPeople, where I want to highlight records that are marked.
I have done this by putting the following code in Detail_Paint:
Dim intUser1 As Integer
intUser1 = Form_NavigationForm.cmbUser
If Not DCount("*", "tblmarkedpeople", "fldPeopleID = " & PeopleID & " AND fldUserID = " & intUser1) = 0 Then
txtContactName.ForeColor = 12500670
Address.ForeColor = 12500670
Else
txtContactName.ForeColor = 404040
Address.ForeColor = 404040
End If
(I cannot remember why I went for "If Not DCount = 0" rather than "If Dcount = 1", but I suppose I probably thought I had a reason at the time...)
This does what I want. The marked records are greyed out.
However, when I apply a filter to the form, I get this:
Run-time error '3705':
Syntax error (missing operator) in query expression 'fldPeopleID = and fldUserID = 1'
Even more weirdly, I have to click the [End] button numerous times (sometimes more than 20) to end the debug. (I am pretty sure that the number of clicks depends on the number of records returned by the filter, but it's not as simple as 1 click per record or anything like that.
I regret to have to say that I apply the filter with a Macro in the after update action of txtSearch (which is in the form header).
I filched this macro from somewhere before I knew how to write any VBA and have never got around to coding it instead. I have no idea whether this would make any difference to this particular error, which seems to make the Detail_Paint code "lose sight" of [PeopleID].
Can anyone please explain why the filter causes this problem and how to fix or get around it?
Many thanks,
George