Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

When a form is open, it won 't showed the filtered record

Status
Not open for further replies.

maupiti

Programmer
Oct 27, 2003
240
US
Access 2003.

I have a form, and within this form is a subform named
"Subform_Search_1". When a record is highlighted on this subform and a button is clicked it supposed
to open another form (Incident_Form) with a filtered record.
The form did opened, but it did not filtered the selected
record.


Form Name: Incident_Form
Record Source: Table_Incident
Filter: [Incident_Number]=10-1-2002-3

///////////////////////////

Private Sub Open_Incident_Form_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Incident_Report"

stLinkCriteria = "[Incident_Number]=" &
Me![SubForm_Search_1].Form!Incident_Number
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub
 
for debugging, put this in and verify it returns what you want

stLinkCriteria = "[Incident_Number]=" &
Me![SubForm_Search_1].Form!Incident_Number
msgbox stLinkCriteria
DoCmd.OpenForm stDocName, , , stLinkCriteria

Check the spelling on "Incident_Number" in the table Tbl_Incident make sure it matches and that it is included in the recordset for the form.
 
How are ya maupiti . . .

Try this:
[/blue] (unless its a typo!) and a pair of single :
Code:
[blue] stLinkCriteria = "[Incident_Number] = [red][b]'[/b][/red]" & [red][b]_[/b][/red] 
    Me![SubForm_Search_1].Form!Incident_Number & "[red][b]'[/b][/red]"[/blue]

Calvin.gif
See Ya! . . . . . .
 
Hi TheAceMan1. I used all three different format and the
Debug.Print stLinkCriteria statement showed the value.
Still, the form did not filtered when it opened.

///////////////////////////////////////////////

stLinkCriteria = "[Incident_Number]=" & "'" & Me![SubForm_Search_1].Form!Incident_Number & "'"
[Incident_Number]=10-1-2002-3

stLinkCriteria = "[Incident_Number]=" & Me![SubForm_Search_1].Form!Incident_Number
[Incident_Number]='10-1-2002-3'

stLinkCriteria = "[Incident_Number] = '" & Me![SubForm_Search_1].Form!Incident_Number & "'"
[Incident_Number]='10-1-2002-3'
 
As AceMan showed you will have to use single quotes since the incident number is really a string. So you are closer because your original would not have worked.
For debugging try this. Build a query using "10-1-2002-3" as your criteria using the query that your form uses. If it returns the correct record, switch to SQL view, copy post the Sql statement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top