I have 2 tables
tbl_Reports_Tabled (key =Report_ID) and tbl_Recommendations (key REC_ID) they are link 1-many by Report_ID, based on the tables I created a Subform with frm_Reports_Table as the parent and frm_Recommendation as the embedded form.
I have built a search form frmSearchREC based on a query which included Report_ID. The search form has a list box that displays all of the recommendation including the Report_ID. A txtbox called txtSearch allows the user to enter free text returning results in the list box (this works well). Once the record is returned in the list box I want the user to click on it and open the frm_Reports_Tabled filtering to the Report_ID in the listbox . I have the following code
Private Sub SearchResults_Click()
On Error GoTo Err_Command24_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frm_Reports_tabled"
stLinkCriteria = "[Report_ID]=" & Me![SearchResults]
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "frmSearchREC", acSaveYes
Exit_Command24_Click:
Exit Sub
Err_Command24_Click:
MsgBox Err.Description
Resume Exit_Command24_Click
End Sub
The code line stLinkCriteria = "[Report_ID]=" & Me![SearchResults] appears to be wrong
When I click on any line in the ListBox example - Report_ID of 2000_83 it returns the following error Syntax error in query expression ‘[Report_ID] = 2000_83
Any help would be greatly received as I have been trying to resolve this for days. Thanks Ron
tbl_Reports_Tabled (key =Report_ID) and tbl_Recommendations (key REC_ID) they are link 1-many by Report_ID, based on the tables I created a Subform with frm_Reports_Table as the parent and frm_Recommendation as the embedded form.
I have built a search form frmSearchREC based on a query which included Report_ID. The search form has a list box that displays all of the recommendation including the Report_ID. A txtbox called txtSearch allows the user to enter free text returning results in the list box (this works well). Once the record is returned in the list box I want the user to click on it and open the frm_Reports_Tabled filtering to the Report_ID in the listbox . I have the following code
Private Sub SearchResults_Click()
On Error GoTo Err_Command24_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frm_Reports_tabled"
stLinkCriteria = "[Report_ID]=" & Me![SearchResults]
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "frmSearchREC", acSaveYes
Exit_Command24_Click:
Exit Sub
Err_Command24_Click:
MsgBox Err.Description
Resume Exit_Command24_Click
End Sub
The code line stLinkCriteria = "[Report_ID]=" & Me![SearchResults] appears to be wrong
When I click on any line in the ListBox example - Report_ID of 2000_83 it returns the following error Syntax error in query expression ‘[Report_ID] = 2000_83
Any help would be greatly received as I have been trying to resolve this for days. Thanks Ron