473,387 Members | 1,722 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,387 software developers and data experts.

Format VB Coding in Reports

So I've never used VB in a report before, but I'm taking a shot at it.

Just as a test to see if I'm doing it right, I'm trying to set up an
invoice where a particular rectangle will change from white to red
depending if the customer has more than one order on file.

I have my query set up, and it's working just fine.

Of the five dummy invoices I have set up, I have the following values
calculated for CountofOrderID, and would expect the following colors
for the rectangle:

3 - Red
1 - White
2 - Red
2 - Red
3 - Red

However, when I view the reports, what I actually get is this:

3 - Red
1 - Red
2 - Red
2 - Red
3 - Red

The underlying code I have is:

Private Sub Renewal_Indicator(Cancel As Integer)

If [CountOfOrderID] 1 Then
RenewalHide.BackColor = 255
Else
RenewalHide.BackColor = 16777215
End If

End Sub

What am I doing wrong? Thanks!

Mar 22 '07 #1
3 2097
On 22 Mar 2007 07:06:51 -0700, da*******@gmail.com wrote:

To debug this, I would temporarily add the CountOfOrderID to the
Details section. And I would set a breakpoint at the top of the
procedure to be able to step through.
Perhaps the code should be in the Format event?

Btw, use the built-in constants vbRed and vbWhite.
>So I've never used VB in a report before, but I'm taking a shot at it.

Just as a test to see if I'm doing it right, I'm trying to set up an
invoice where a particular rectangle will change from white to red
depending if the customer has more than one order on file.

I have my query set up, and it's working just fine.

Of the five dummy invoices I have set up, I have the following values
calculated for CountofOrderID, and would expect the following colors
for the rectangle:

3 - Red
1 - White
2 - Red
2 - Red
3 - Red

However, when I view the reports, what I actually get is this:

3 - Red
1 - Red
2 - Red
2 - Red
3 - Red

The underlying code I have is:

Private Sub Renewal_Indicator(Cancel As Integer)

If [CountOfOrderID] 1 Then
RenewalHide.BackColor = 255
Else
RenewalHide.BackColor = 16777215
End If

End Sub

What am I doing wrong? Thanks!
Mar 22 '07 #2
On Mar 22, 10:42 am, Tom van Stiphout <no.spam.tom7...@cox.netwrote:
On 22 Mar 2007 07:06:51 -0700, dancol...@gmail.com wrote:

To debug this, I would temporarily add the CountOfOrderID to the
Details section. And I would set a breakpoint at the top of the
procedure to be able to step through.
Perhaps the code should be in the Format event?

Btw, use the built-in constants vbRed and vbWhite.
So I've never used VB in a report before, but I'm taking a shot at it.
Just as a test to see if I'm doing it right, I'm trying to set up an
invoice where a particular rectangle will change from white to red
depending if the customer has more than one order on file.
I have my query set up, and it's working just fine.
Of the five dummy invoices I have set up, I have the following values
calculated for CountofOrderID, and would expect the following colors
for the rectangle:
3 - Red
1 - White
2 - Red
2 - Red
3 - Red
However, when I view the reports, what I actually get is this:
3 - Red
1 - Red
2 - Red
2 - Red
3 - Red
The underlying code I have is:
Private Sub Renewal_Indicator(Cancel As Integer)
If [CountOfOrderID] 1 Then
RenewalHide.BackColor = 255
Else
RenewalHide.BackColor = 16777215
End If
End Sub
What am I doing wrong? Thanks!
It does the same thing whether it's in Details or the Group Header.

What's a breakpoint?

Mar 22 '07 #3
<da*******@gmail.comwrote
It does the same thing whether it's in
Details or the Group Header.
Help me understand... your code is a Private Sub named RenewalIndicator...
what is it that you expect to cause this code to execute? At execution
time, the events in a Report that cause code to be executed are the Format
and Print events for a Section -- your code will need to be either called
from, or included in, the Format or Print event for the Report Section where
the Controls reside.
What's a breakpoint?
A "breakpoint" is a debugging aid, set from the toolbar in a code window, on
a line of code -- when execution reaches that line of code, execution stops,
and the VBA code is displayed so you can use the Immediate Window, etc., to
debug your code.

I'd suggest a bit more study on VBA in Access, how it works, what it does,
and how to use it before you launch into writing your own. I believe there
are some recommendations for self-study texts in the FAQ at
http://www.mvps.org/access.

Some people I know have a book that is expected to be published in May of
this year... the lead author is Teresa Hennig, and I believe it is already
listed at amazon.com. John Viescas' Access 2003 Inside/Out includes an
introduction to VBA, but not "in-depth" developer training.

Larry Linson
Microsoft Access MVP
Mar 22 '07 #4

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

Similar topics

1
by: Shaileen Patel | last post by:
Hi, I am trying to convert a lot of web reports from ASP/VB to ASP.NET/VB.NET. I would like to save my dataset in XML and then use XSLT to transform the XML. The catch is I would like to have...
3
by: marwa mohamed | last post by:
salamo alikom hi all when i run report that includes image control linked to a field in the table that contains the image path(on the server)and the record source of the report contains over 30...
1
by: Johnny Gee | last post by:
Hi All I have a macro that I use to send three reports every week to about 10 people by email via Lotus Notes.I use the "Send To" command to send the reports out in Rich Text Format. I used RTF...
3
by: kmacon | last post by:
I have a form that contains a command button. The command button's OnClick event builds a report using the CreateReport and CreateReportControl functions and then opens the main report. I set...
0
by: CK | last post by:
There have been a few postings asking if there is an alternative to Crystal Reports for a web based web reporting solution. Access2PDF is the software solution for developers looking for an easy...
7
by: Robert Seacord | last post by:
The CERT/CC has just deployed a new web site dedicated to developing secure coding standards for the C programming language, C++, and eventually other programming language. We have already...
16
by: Mik | last post by:
I apologise if this post seems a little basic, but I am a newbie and have NO access knowledge. I have downloaded the Accounts Ledger from the Microsoft Website. It allows the user to review a...
2
by: Priyavenkat | last post by:
i am using VB 6.0, MS Access as backend and Crystal Reports 10 for reports. I connect data source to Crystal Reports 10 using ODBC dsn. It works correctly in my PC. When it is distributed to another...
1
by: khushbu shah | last post by:
C# ASP.Net Note:- column names are dynamic based on report. commn function is used for number of reports. private void exportDataTableToCsv(DataTable formattedDataTable, string filename) ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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,...

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.