473,397 Members | 2,116 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Filter Report Using Subroutine Variable

2
I am relatively new to using VBA and am have been trying for two days to pass a user entered value to my report for filtering when opened. I have the following subroutine in the open event of my report:
Private Sub Report_Open(Cancel As Integer)

'Prompts for business unit when run educational assistance reports.

Dim strBusUnitName As String

strBusUnitName = UCase(InputBox("Enter Business Unit or click OK for all.", "Business Unit", "All"))

Me.Filter = ""
Select Case strBusUnitName

Case Is = "DB17A", "DB50A", "DB69A", "DB70A", "DB71A", "DB85A"
Me.Filter = "[EmpBusinessUnit]= " & strBusUnitName
Me.FilterOn = True
Case Is = "ALL"
Me.FilterOn = False
Case Is = ""
Me.FilterOn = False
Cancel = True
Case Else
MsgBox "Business Unit Not Found. Please Verify and Retry."
Cancel = True
End Select
When my form opens I am prompted for the business unit. When a valid business unit is entered Access brings up a second prompt with the title: "Enter Parameter Value" with the value of my filter variable where the text prompt would go: (ex. DB69A would show as the text for the second prompt).

Can someone please tell me how to get rid of this second prompt and get access to use the value I am passing in variable strBusUnitName to filter the report.

Thank you.
Nov 17 '08 #1
2 2614
jim190
2
I don't know if it is good protocol to answer your own post, but here is the solution for those of you who run into a similar problem:

The syntax for a string variable passed as a filter is as follows:
Me.Filter = "[EmpBusinessUnit] = '" & strBusUnitName & "'"
DQ = Double Quote sq = Single Quote as follows:

DQ[EmpBusinessUnit] = sqDQ & strBusUnitName & DQsqDQ

This is wild but it is correct.

Thanks to PSchiele at the following link for having posted this solution to a post from 1999 - Wow. {Tek-Tips - PSchiele Post 1999}
Nov 17 '08 #2
NeoPa
32,556 Expert Mod 16PB
We're quite happy for you to post a solution Jim. Unfortunately, due to our rules, I have had to remove the link to a competing forum.

You can find a discussion of the topic here at Quotes (') and Double-Quotes (") - Where and When to use them.
Nov 17 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: deko | last post by:
I can't move a multi-page report to the last record unless I keep the popup form (that defined it's subreports) open. DoCmd.OpenReport "rptStandard", acViewNormal DoCmd.Close acForm,...
0
by: CSDunn | last post by:
Hello, I have a problem with field filtering between an Access 2000 Project form (the application is called CELDT), and the report that shows the results of the filter. Both the form and the...
3
by: Richard | last post by:
Hi, I have a form based on a table. When I filter the form I want to run a report based on the same table with the same filter as the form. No problem until I want to filter a combo box where...
3
by: jason | last post by:
I'll try to explain in detail what it is I'm struggling with. I created a SQL database with one table called CallSheet which contains the following columns: Caller ID: <--Primary Key, auto...
1
by: lorirobn | last post by:
Hi, I have a report that works just fine. Now I would like to add the capability to choose selection criteria to limit what is displayed. I created several reports that do this, but they used...
2
by: Thall | last post by:
Hey Gurus - I've seen a few solutions to this problem, but none of which I can do without a little help. Here's the situation The following code loops thru a sales report, using the sales rep ID...
17
imrosie
by: imrosie | last post by:
Hello, I've gone through the tutorials, and searched. Still I can't find a clear solution to my issue. I have a form with a subform that displays a listbox control called 'theOrderID'. I have...
3
by: franc sutherland | last post by:
Hello, I have a report which I filter using the me.filter command in the OnOpen event. Me.Filter = "OrderID=" & Forms!variable_form_name! Me.FilterOn = True I want to be able to open that...
3
by: Gord | last post by:
I'm trying to filter a report with a date in VB code. If I type an actual date bracketed with the pound symbol (i.e. #3-Jul-08#) I can get the filter to work. I can't seem to get it to work by...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.