Filter Problem on a form built from a query

Les Blair

Registered User.
Local time
Today, 10:16
Joined
Sep 10, 2007
Messages
49
I have a tbl that I do a search on and when I get the results I place the record selector beside the record I want to look at and then press the View Detail cmd button. It takes me to the form I want but does not show the record I am looking for. The form is built from a query.

Here is the code behind the view detail:

Private Sub cmdViewDetail_Click()
Dim strLinkCriteria As String
Dim strDocName As String

If Not IsNull(Me.txtCaseTrack) Then
strLinkCriteria = ([Case Track Nbr] = """ Me.txtCaseTrack & """)
End If

If Me.txtCaseType = "MED" Then
If Me.txtLocation = "Prospects" Then
strDocName = "frmMedProspects"
DoCmd.OpenForm strDocName, , , , acFormEdit
Me.Filter = strLinkCriteria
Me.FilterOn = True
End If
Else
......
End If

This takes me to the correct screen but does not find the record it does not even appear that it tried to locate the record. It just shows the first record in the query result as if no find has been requested.

Please if someone has an answer I would appreaciate the help.
 
Instead of using:

Me.Filter = strLinkCriteria
Me.FilterOn = True

Which would be filtering the original form that your command button is on (not the one you are opening) use:

Forms!frmMedProspects.Filter = strLinkCriteria
Forms!frmMedProspects.FilterOn = True

Also, this part is slightly off:
strLinkCriteria = ([Case Track Nbr] = """ Me.txtCaseTrack & """)

Just use:
strLinkCriteria = "[Case Track Nbr] = '" & Me.txtCaseTrack & "'"
 

Users who are viewing this thread

Back
Top Bottom