Hi,
I have a form bound to a table and I try to filter the reccords in the open form event.
My problem is that the field that supports the filter : "strCréateur" (creator in french) is a combination of to fields in an other table "strNom" (LastName) and "strPrénom" (LastName)
In addition to this I use DLookup to automaticaly get the Last and FirstName in the other table called "tblUsers" where they have to match environ("username") (I have access 2002).
I don't know if what I said is understandable so I'll let the code speak for itself
Here are my non working shots :
'FILTER IN ORDER TO DISPLAY ONLY THE RECCORDS WHERE THE USER IS CREATOR
Private Sub Form_Open(Cancel As Integer)
Dim Nom As String
Dim Prénom As String
Nom = DLookup("[strNom]", "tblUsers", "[strIGGID]= " & Environ("username") & "'") 'gets the Last name of the connected user and puts it in the variant Nom
Prénom = DLookup("[strPrénom]", "tblUsers", "[strIGGID]= " & Environ("username") & "'")'gets the First name of the connected user and puts it in the variant Prénom
DoCmd.ApplyFilter , "[strCréateur] = " & Nom & " " & Prénom
End Sub
I also tried things like :
'Home made starts with
DoCmd.ApplyFilter , "[strCréateur] = " & DLookup("[strNom]", "tblUsers", "[strIGGID]= " & Environ("username") & "'") & "*"
'No variant declaration
DoCmd.ApplyFilter , "[strCréateur] = " & DLookup("[strNom]", "tblUsers", "[strIGGID]= " & Environ("username") & "'") & " " & DLookup("[strPrénom]", "tblUsers", "[strIGGID]= " & Environ("username") & "'")
And I tried to play with the "'" '" & "'" ="& = & &"... but didn't work
The weirdest part is that when I have this code in my form if I double click on the form in the database window nothing happens, not even an error message, I'm confused.
Thank you in advance for your suggestions.
I have a form bound to a table and I try to filter the reccords in the open form event.
My problem is that the field that supports the filter : "strCréateur" (creator in french) is a combination of to fields in an other table "strNom" (LastName) and "strPrénom" (LastName)
In addition to this I use DLookup to automaticaly get the Last and FirstName in the other table called "tblUsers" where they have to match environ("username") (I have access 2002).
I don't know if what I said is understandable so I'll let the code speak for itself
Here are my non working shots :
'FILTER IN ORDER TO DISPLAY ONLY THE RECCORDS WHERE THE USER IS CREATOR
Private Sub Form_Open(Cancel As Integer)
Dim Nom As String
Dim Prénom As String
Nom = DLookup("[strNom]", "tblUsers", "[strIGGID]= " & Environ("username") & "'") 'gets the Last name of the connected user and puts it in the variant Nom
Prénom = DLookup("[strPrénom]", "tblUsers", "[strIGGID]= " & Environ("username") & "'")'gets the First name of the connected user and puts it in the variant Prénom
DoCmd.ApplyFilter , "[strCréateur] = " & Nom & " " & Prénom
'Displays a message if there is no reccords found
If Not FormHasData(Form) Then
MsgBox "Your did not create any of the boxes in the database" & Err.Description, vbExclamation, "Créateur inexistant"
End If
If Not FormHasData(Form) Then
MsgBox "Your did not create any of the boxes in the database" & Err.Description, vbExclamation, "Créateur inexistant"
End If
End Sub
I also tried things like :
'Home made starts with
DoCmd.ApplyFilter , "[strCréateur] = " & DLookup("[strNom]", "tblUsers", "[strIGGID]= " & Environ("username") & "'") & "*"
'No variant declaration
DoCmd.ApplyFilter , "[strCréateur] = " & DLookup("[strNom]", "tblUsers", "[strIGGID]= " & Environ("username") & "'") & " " & DLookup("[strPrénom]", "tblUsers", "[strIGGID]= " & Environ("username") & "'")
And I tried to play with the "'" '" & "'" ="& = & &"... but didn't work
The weirdest part is that when I have this code in my form if I double click on the form in the database window nothing happens, not even an error message, I'm confused.
Thank you in advance for your suggestions.