473,503 Members | 12,175 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help in report

39 New Member
Hi
i have an report with fields Student Name ,Roll No ,subI subII,SubIII,subIV In which i to sum all sub. so i add unbound txtbox and in controlsource add expression =(subI)+(subII)+(SubII)+(subIV). It work perfectly when all sub having marks but from 4 sub only 3 are compulsory and one optional so when optional sub not having marks sum is not take place and when i add zero to optional sub sum take place but i want add dashes (--) in that sub than zero. How can i do this
Jun 19 '16 #1
6 1112
Narender Sagar
189 New Member
Let's assume Sub4 is optional. You can create two columns in a query. In first column give it a name e.g. Sub4a : Apply "if" formula something like : IIf([Sub4]>0,[Sub4],0) and do calculation part based on this column of the query.
Create another column in the query e.g. Sub4b : Apply "if" formula again something like : IIf([Sub4]>0,[Sub4],"-") and display this field in report/form.
So my point is : for display purpose you can use 'Sub4b' and for calculation purpose use 'Sub4a'
Jun 19 '16 #2
PhilOfWalton
1,430 Recognized Expert Top Contributor
Try

expression =Nz(subI)+Nz(subII)+Nz(SubIII)+Nz(subIV)
In other words, if one of the Sub is blank, treat it as .

Phil
Jun 19 '16 #3
Narender Sagar
189 New Member
Phil, this will definitely resolve calculation part, however, they also want that the value should appear either the number or (--) dashes, instead of zeros (0).
Thanks
Jun 20 '16 #4
PhilOfWalton
1,430 Recognized Expert Top Contributor
Not too difficult.
On your report, create 4 labels identical in size to the Sub... box
The label caption is "--" your dashes. Aligned Right and the same border as your Sub.. Text box.
Put those labels directly over their corresponding text boxes.

Now we need a bit of code to either show the text box or the label.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  2.  
  3.     If Nz(SubI) = 0 Then
  4.         SubIDash.Visible = True
  5.         SubI.Visible = False
  6.     Else
  7.         SubIDash.Visible = False
  8.         SubI.Visible = True
  9.     End If
  10.  
  11.     If Nz(SubII) = 0 Then
  12.         SubIIDash.Visible = True
  13.         SubII.Visible = False
  14.     Else
  15.         SubIIDash.Visible = False
  16.         SubII.Visible = True
  17.     End If
  18.  
  19.     If Nz(SubIII) = 0 Then
  20.         SubIIIDash.Visible = True
  21.         SubIII.Visible = False
  22.     Else
  23.         SubIIIDash.Visible = False
  24.         SubIII.Visible = True
  25.     End If
  26.  
  27.     If Nz(SubIV) = 0 Then
  28.         SubIVDash.Visible = True
  29.         SubIV.Visible = False
  30.     Else
  31.         SubIVDash.Visible = False
  32.         SubIV.Visible = True
  33.     End If
  34.  
  35. End Sub
  36.  
  37.  
Phil
Jun 20 '16 #5
jforbes
1,107 Recognized Expert Top Contributor
Another option is to perform the substitution in the ControlSource of your unbound TextBox. You can change your ControlSource to something like this:
Expand|Select|Wrap|Line Numbers
  1. =IIf(NZ([subI],0)=0 OR NZ([subII],0)=0 OR NZ([SubII],0)=0 OR NZ([subIV],0)=0 ,"-",[subI]+[subII]+[SubII]+[subIV])
Jun 20 '16 #6
sachuchem22
39 New Member
Thanks to all you i will try your solution and i hope it help me.
Jun 21 '16 #7

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

Similar topics

5
2785
by: MGFoster | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I've converted an ACC97 .mdb file to an ACC2K2 .adp. A report that worked in ACC97 doesn't work in ACC2K2. Report setup: ACC97 ...
1
1535
by: Simon Matthews | last post by:
Hope someone can help an Access beginner! I've just started keeping my surgical logbook on access and it's a simple flat-file affair. I have created several queries that will list cases...
0
1076
by: BFord | last post by:
Using Acc2000, only the report itself not printing. The following have been tested, with no problem: 1) the print drivers are fine. 2) printed the query (source of the report) 3) printed...
5
2187
by: Steve Patrick | last post by:
Hi All You guys are my last hope, despite spending money on books and hours reading them I still can not achieve the results I need. I have designed a database in Access 2000 based on 1 table,...
6
4959
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
5
2479
by: AdrianE | last post by:
I have a database where a record has a start date and an end date and is linked to an employee. Ho do I create a report that will show each employee and gaps between the employees next record...
6
3331
by: darktiger | last post by:
Okay I have a report that uses a query to pull multiple info from different tables. Some of the information is Total # of applicants which is to be pulled from different values such as "Hispanic,...
3
1762
by: DeanL | last post by:
Hi guys, I'm in need of a little help with a report I'm setting up on Access 2000. The report shows data depending on entries on a form that has 7 fields (Min and Max Cost, Fiscal Year, Min and...
6
9377
by: Dave | last post by:
On my form I have combo boxes. These combo boxes, after updating them, populate respective listboxes that are located below the combo boxes on the same form. I am trying to use a "generate...
12
3510
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to...
0
7193
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
7067
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
7449
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...
0
5562
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
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1495
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 ...
0
371
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...

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.