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 Criteria for Report

Status
Not open for further replies.

misscrf

Technical User
Jun 7, 2004
1,344
US
I have a combo box on a form to filter a report that is (for this project) by attorney. You can choose which attorney to show the report for. This is the code that I have:

Code:
Private Sub cmdrptAttorney_Click()
On Error GoTo Err_cmdrptAttorney_Click

    Dim stLinkCriteria As String
    stLinkCriteria = Me.cboAttorney
   
    DoCmd.OpenReport gstrReportName, acPreview, , "CLeadAttorney =" & stLinkCriteria, acWindowNormal
    
Exit_cmdrptAttorney_Click:
    Exit Sub

Err_cmdrptAttorney_Click:
If Err <> 2501 Then
    msgbox Err.Description
  End If
    Resume Exit_cmdrptAttorney_Click
End Sub

The gstrReportName is passed as an openargs from a previous reports form.

CLeadAttorney is a field in tblCases and is linked to tblAttorney lookup, storing the attorney's ID.

cboAttorney, or stlinkcriteria, has the following rowsource as it is unbound:

Code:
SELECT tblCases.CLeadAttorney, tblAttorney.AttFirstName, tblAttorney.AttLastName FROM tblCases LEFT JOIN tblAttorney ON tblCases.CLeadAttorney=tblAttorney.AttTimeKeeper GROUP BY tblCases.CLeadAttorney, tblAttorney.AttFirstName, tblAttorney.AttLastName ORDER BY tblAttorney.AttLastName;

Can anyone help? Did I miss any needed information? Please let me know if I did.

Thank you,

misscrf

It is never too late to become what you could have been ~ George Eliot
 
oh, sorry. When I choose an attorney, and click to get the report, I get a "data type mismatch in criteria expression."

Thanks!

misscrf

It is never too late to become what you could have been ~ George Eliot
 
Your error message states "data type" yet you don't provide us with any information regarding the "data type" of your fields :-(

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]
 
nevermind. I figured it out. Thanks.

misscrf

It is never too late to become what you could have been ~ George Eliot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top