473,668 Members | 2,654 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

In Access 2003, how to: output a value, followed by a percent sign (%), from a SQL query on a Report

Hello world:

I'm having trouble finding how to escape the percent sign ("%") from a SQL
query
so that it will show up in an Access report. Here's my SQL string ...

'--Build SQL String
strSQL = ""
strSQL = strSQL & "SELECT tblSubscriberAc tivity.PERIOD, "
strSQL = strSQL & "Sum(tblSubscri berActivity.AVG _SUBS) AS AVG_SUBS, "
strSQL = strSQL & "Sum(tblSubscri berActivity.NET _DEACTS) AS NET_DEACTS, "
strSQL = strSQL & "CSTR(ROUND(Sum (tblSubscriberA ctivity.NET_DEA CTS)/"
strSQL = strSQL & "Sum(tblSubscri berActivity.AVG _SUBS),3)*100) AS CHURN "
strSQL = strSQL & "FROM tblSubscriberAc tivity "
strSQL = strSQL & "GROUP BY tblSubscriberAc tivity.PERIOD "
strSQL = strSQL & "HAVING tblSubscriberAc tivity.PERIOD In (" & strPeriod &
");"

The above SQL code works and produces a nice (for example) "5.9" value for
CHURN.
However, if I want it to produce "5.9%", I can't do it. I have tried using
Chr(37), but that
doesn't work. There MUST be a way to do this! Can anyone help?

Alan
Nov 13 '05 #1
1 3775
On Thu, 30 Dec 2004 03:26:57 GMT, "Alan Lane" <aw*****@yahoo. com>
wrote:

Set the Format property for that field in the report to Percent.
Then divide your results by 100, so you get 0.059, which will then
correctly display as 5.9%

-Tom.

Hello world:

I'm having trouble finding how to escape the percent sign ("%") from a SQL
query
so that it will show up in an Access report. Here's my SQL string ...

'--Build SQL String
strSQL = ""
strSQL = strSQL & "SELECT tblSubscriberAc tivity.PERIOD, "
strSQL = strSQL & "Sum(tblSubscri berActivity.AVG _SUBS) AS AVG_SUBS, "
strSQL = strSQL & "Sum(tblSubscri berActivity.NET _DEACTS) AS NET_DEACTS, "
strSQL = strSQL & "CSTR(ROUND(Sum (tblSubscriberA ctivity.NET_DEA CTS)/"
strSQL = strSQL & "Sum(tblSubscri berActivity.AVG _SUBS),3)*100) AS CHURN "
strSQL = strSQL & "FROM tblSubscriberAc tivity "
strSQL = strSQL & "GROUP BY tblSubscriberAc tivity.PERIOD "
strSQL = strSQL & "HAVING tblSubscriberAc tivity.PERIOD In (" & strPeriod &
");"

The above SQL code works and produces a nice (for example) "5.9" value for
CHURN.
However, if I want it to produce "5.9%", I can't do it. I have tried using
Chr(37), but that
doesn't work. There MUST be a way to do this! Can anyone help?

Alan


Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
5406
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very predictable and consistent. Since moving to a WinNT/UDB 7.2 environment, the choices the optimizer makes often seem flaky. But this last example really floored me. I was hoping someone could explain why I get worse response time when the optimizer uses two indexes, than when it uses one. Some context:
3
23452
by: Jon Ole Hedne | last post by:
My Access 2002-application need to work with tables from both Oracle and Access. To solve this, I want to run some querys on three views in Oracle and import the results into temporary Access-tables. I have tried this: conn.Provider = "Microsoft.Jet.OLEDB.4.0" conn.ConnectionString = "data source=" & datafil & ";Jet OLEDB:Database Password=" conn.Open datafil
6
4739
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much appreciated. Thanks in advance
8
3509
by: Mike MacSween | last post by:
tblCourses one to many to tblEvents. A course may have an intro workshop (a type of event), a mid course workshop, a final exam. Or any combination. Or something different in the future. At the moment the printed output is usually going to Word. It's turning into an unholy mess, because I'm having to prepare umpteen different Word templates, and the queries that drive them, depending on what events a course has.
52
9956
by: Neil | last post by:
We are running an Access 2000 MDB with a SQL 7 back end. Our network guy is upgrading to Windows Server 2003 and wants to upgrade Office and SQL Server at the same time. We're moving to SQL Server 2005, and, since he already has licenses for Office Pro 2002, he wants to upgrade to that. I've been saying that we need to upgrade to Access 2003, not 2002, even if Office is kept at 2002. We are also looking to do a fair amount of...
14
16881
by: pdavis06 | last post by:
I know that there is a thread about this, but I was unable to add to it; I just joined. The problem is that I do not want to change the date format for the entire database output, merely for a header on a report and for a field on that report. I thought that I could just go into the expression builder and paste one of the codes that were posted in the thread about this conversion-you'll know that did not work. So, I went to the new...
1
4096
by: bobykim | last post by:
Hi All, I'm using MS Access 2003 in a Windows XP environment. I've created an aging report for my department that is based on what I call the "Main query" with an IIf statement that allows the user to define the dates into 30 day aging segments. Then I've created a crosstab query which counts the results. How I'd like the report to appear is like this: Entity_Type | 1 to 30 days | 31 to 60 days | Over 60 days OPFACT ...
23
2542
by: helm | last post by:
Folks, could anyone advise ... Is there a significant difference in crosstab capabilities in Access and Excel? Using Office XP 2002 ... to produce a crosstab report I developed it in Excel from a query datasource in Access. One good thing about this was the ability to select both a date header and then a specific time header for the crosstab value. Try as I might, I cannot see a way to replicate this in Access either directly using a...
5
2874
by: accesstruggle | last post by:
Hello, I am having trouble with my database in Access. The problem lies in my report. I have created a report based off a query. The query contains all values that I'll need for my report- some will be directly on the report in text boxes, etc and others will be needed for calculations only and so are not directly on the report. My problem is when I'm writing the code for my text box "TriagePercent" which should, based on the AuditNum (pk)...
0
8462
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8893
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8797
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8583
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8656
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7401
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6209
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2791
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1786
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.