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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo box parameter as filter to query and load report

Status
Not open for further replies.

redbanana

Programmer
Apr 26, 2007
1
US
Hi, I'm new to this, so I know it is probably very easy for you!

I have an Access form with a combo box: cmbEmpID

I want to take the select empID and use it in a query against table tblRecords.

essentially, Select * from tblRecords Where empID = cmbEmpID;

I want that record set returned into a report.

How do I do this?
 
Use the command button wizard to create a button that opens your report. Then right-click the button and choose Build... Then add code to your click event sub like:
Code:
Dim strWhere as String
If Not IsNull(Me.cmbEmpID) Then
    'assuming EmpID is numeric
    strWhere = "[EmpID]=" & Me.cmbEmpID
End If
DoCmd.OpenReport "rptName", acPreview, , strWhere

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top