473,467 Members | 1,768 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Change a field in a report.

489 Contributor
I don't know if this can be done but thought I'd ask anyway, as there are lots of very smart people out there.
I have a report that shows a persons time it took to complete a task. If he doesn't complete the task he gets a time of 999 when printing the report that shows only the times I would like to change the 999 to a DNF (did not finish). I don't want to change the record only have it show up on the report. There are many different task so one person could have two or more 999 that need to be changed to the DNF.
Is this possible of should I just leave the 999.
Thanks for any advice.

Tom
May 4 '12 #1

✓ answered by Stewart Ross

You don't need to do anything in VBA code at all. Use a query and add a computed field, something like this (with placeholders for the field names, as you haven't told us them)

Expand|Select|Wrap|Line Numbers
  1. SELECT [first field], [second field], ...,
  2.        IIF([YourTimeField]=999, "DNF", [YourTimeField] AS [MixedTime]
  3.        FROM [Your Table]... 
You'd base your report on the new query instead of the table. You then have access to the aliased field - MixedTime in the example above.

If you don't want to use a query to do so you can instead add a textbox to the report and set its control source property to

=IIF([YourTimeField]=999, "DNF", [YourTimeField])

but you'd have to have an instance of field [YourTimeField] on the report - with its visible property set to No if you don't want it to come out on the report.

No need to use VBA at all...

-Stewart

4 2448
Rabbit
12,516 Recognized Expert Moderator MVP
Use the IIf() function to return DNF if they didn't finish the task.
May 4 '12 #2
CD Tom
489 Contributor
Can I change the field even if it's a numeric field and I'm putting in a string?
May 5 '12 #3
CD Tom
489 Contributor
Expand|Select|Wrap|Line Numbers
  1. i = vtask
  2. For i = 1 to vtask
  3. Vtime = "task" & i
  4. me(vtime).value = iif(me(vtime) = 999, "DNF", me(vtime))
  5. next i
when I use this code it gives me an error "you can't assign a value to this object" I'm sure that this is because it's trying to change the underline record. Is there any way to only change the report and leave the underline record unchanged?
I hope this makes sense.

Thanks
May 5 '12 #4
Stewart Ross
2,545 Recognized Expert Moderator Specialist
You don't need to do anything in VBA code at all. Use a query and add a computed field, something like this (with placeholders for the field names, as you haven't told us them)

Expand|Select|Wrap|Line Numbers
  1. SELECT [first field], [second field], ...,
  2.        IIF([YourTimeField]=999, "DNF", [YourTimeField] AS [MixedTime]
  3.        FROM [Your Table]... 
You'd base your report on the new query instead of the table. You then have access to the aliased field - MixedTime in the example above.

If you don't want to use a query to do so you can instead add a textbox to the report and set its control source property to

=IIF([YourTimeField]=999, "DNF", [YourTimeField])

but you'd have to have an instance of field [YourTimeField] on the report - with its visible property set to No if you don't want it to come out on the report.

No need to use VBA at all...

-Stewart
May 5 '12 #5

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

Similar topics

1
by: Alex Stevens | last post by:
Hi All, I have implemented my own toolbar on a form which houses the crystal reprot viewer. I would like to have a combobox to allow the user to change the zoom level to say 25 / 50 / 75 / 100...
1
by: Lumpierbritches | last post by:
Thank you in advance for any and all assistance, it is greatly appreciated. I have tables that have a field that I want to change from Dam to Female and Sire to Male. Is there simple code to loop...
7
by: Henry | last post by:
I am writing a Windows forms VB.Net/MS SQL application via VS 2003 that utilizes Crystal Reports. I want to be able to dynamically set the report data source at run time. I'm trying to change...
1
by: Bruce HS | last post by:
Report designer gives you lots of nice ways to build queries, add parameters, filters, etc. However, I need more control of the query at run time. Can my VS 2005 VB WinForms application call an...
3
by: alphaomega3 | last post by:
Is there a way to change field names throughout my db? I erroneously named a date field as "Date" and should have been named something else cause this may cause me problems as I start using this...
0
by: Sheoak | last post by:
Hi, I am developing Crystal Reports using VC++.Net Unlike VB.Net in the VC++.Net there is no report objects. How do I change the report's page layout to landscape in the IDE and also...
4
by: Bob | last post by:
Hi all, I've got a table that I've imported and it has junk at the top of the table, so after import I run a delete query to remove the junk lines then I'm left with the field names I want for...
1
by: Mannyf50 | last post by:
Hey guys, i have a report with categories that are all a different color, could be Red, Yellow, or purple, im creating a report with the invinsible column where the color will be, the point would...
0
by: Fidell | last post by:
I am using data report with ms access database. I want to the rptTextbox color to change based on the value of the the recordset field. Eg to appear red if the field is "FAIL" and black if it "PASS"....
7
OuTCasT
by: OuTCasT | last post by:
I know how to change the database and sqlserver for a crystal report Dim report As New ReportDocument Dim connection As IConnectionInfo Dim oldServerName As String =...
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:
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
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...
1
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...
0
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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.