chrisb1981
Registered User.
- Local time
- Today, 18:02
- Joined
- Feb 7, 2007
- Messages
- 13
I currently have the code below which filters the form depending on who should have access to which records. It all works fine but now I want to add in an extra filter criteria. So basically I need the Me.Filter(shown in red) changed to include DeleteRecord="0" (field in tblContacts) which will hide records marked as deleted but I don't know how to change it.
Code:
Private Sub Form_Open(Cancel As Integer)
Dim RetVal As Long
Dim RetValGroupID As Long
RetVal = Nz(DLookup("RepID", "tblreps", "NTLogin ='" & Environ("UserName") & "'"), -1)
RetValGroupID = Nz(DLookup("GroupID", "tblreps", "NTLogin ='" & Environ("UserName") & "'"), -1)
If Environ("UserName") = "chris.butler" Then
Me.FilterOn = False
Else
If Environ("UserName") = "caroline.mulvihill" Then
Me.FilterOn = False
Else
If Environ("UserName") = "caroline.farrell" Then
Me.FilterOn = False
Else
If RetVal = -1 Then
MsgBox "Main user does not exist, closing form...."
DoCmd.Close acForm, Me.Name
Else
[COLOR="Red"]Me.Filter = "RepID=" & RetVal & " OR GroupID=" & RetValGroupID[/COLOR]
Me.FilterOn = True
End If
End If
End If
End If
End Sub