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

user friendly criteria entry?

Status
Not open for further replies.

bravo6

IS-IT--Management
Mar 23, 2006
83
US
I am designing a report for my company. We want to be able to allow the user to select which branch(es) they want to include in the query. It's easy to make it work by seting the branch criteria to be: (EXAMPLE)
[enter branchA] Or [enter branchB] Or [enter branchC]
This allows them to enter 1, 2 or 3 branches.
The problem is that they may not know or remember the branch number format such as "0001". If they put in "01" it won't work.
Is there a way to create a drop down box, radio buttons or list for this input so all they have to do is choose?

Thanks,
Dave
 
With most of my projects I have a form that is centered around reporting.

It sounds like you are just at the beginning of designing the reporting tools you'll need for your users.

My form usually contains a list of reports, printer options, margin controls, landscape vs. portrait.

So with that in mind, you should create a form that houses the controls you'll need to setup your report.

Start with the report list, or just a print button for your report, also, have your drop down box, populate it with your SiteID and the User Friendly Name of the site in two columns.

Use the WhereCondition to restrict the records to your siteid

such as:


docmd.openreport "myreport",,,"SiteID=" & cmbSiteSelection

Mark P.
Providing Low Cost Powerful Point of Sale Solutions.
 
You can use a Listbox with the multi-select property set to Simple. Then use code to capture the data and use it as the criteria for the query used by the report. This example uses query qryRpt as the RecordSource for report rptEmpSQL and the last names are shown in the Listbox named lst1, but it captures the EmployeeID #.

Private Sub cmdRpt_Click()
Dim strSQL As String
Dim db As DAO.Database, qdf As DAO.QueryDef
Set db = CurrentDb
Dim var
On Error Resume Next
DoCmd.DeleteObject acQuery, "qryRpt"
On Error GoTo errHandler
strSQL = "Select * From Employees Where employeeID In("
For Each var In lst1.ItemsSelected
strSQL = strSQL & lst1.ItemData(var) & ", "
Next var
strSQL = Left(strSQL, Len(strSQL) - 2) & ")"
Set qdf = db.CreateQueryDef("qryRpt", strSQL)
DoCmd.OpenReport "rptEmpSQL", acViewPreview
errExit:
Exit Sub
errHandler:
MsgBox Err.Number & " : " & Err.Description
Resume errExit
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top