I have a report that uses a parameter query to produce results. The query and report work as expected. That is when I open the report a box pops up asking me to enter a value. What I want to do is have a command button on a Form that when click occurs the report will open with the SkillID field equal to the txtSkillID field on the form.
This is the code I have in the query that generates the report.
The question is how can I trigger the report from a command button so that the underlying query perameter (SkillID) is set to the value txtSkillID?
This is the code I have in the query that generates the report.
Code:
SELECT Employees.[Last Name], Employees.[First Name], tblSkillsLKU.[Skill Name], Skills.Score, Skills.SkillID
FROM tblSkillsLKU RIGHT JOIN (Employees INNER JOIN Skills ON Employees.[Employee ID] = Skills.[Employee ID]) ON tblSkillsLKU.SkillID = Skills.SkillID
WHERE (((Skills.SkillID)=[Forms]![frmFilteredSkillsListBox]![txtSkillID]))
ORDER BY Skills.Score DESC;{/code]
The where clause shows the criteria I have in the query.
Here is what I have behind the command button:
[code]Private Sub cmdPreviewSkills_Click()
On Error GoTo cmdPreviewSkills_Click_Err
Forms![frmEmployee Details].Visible = False
DoCmd.OpenReport "rptWhoHasSkill", acViewPreview, "", "", acNormal
cmdPreviewSkills_Click_Exit:
Exit Sub
cmdPreviewSkills_Click_Err:
MsgBox Error$
Resume cmdPreviewSkills_Click_Exit
End Sub
The question is how can I trigger the report from a command button so that the underlying query perameter (SkillID) is set to the value txtSkillID?