473,320 Members | 2,111 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,320 software developers and data experts.

vb6 Data Report - Change text color at Runtime

5
Hi, Please anyone out there can help me!!!!!!!!!!!!
I am building a Data Report in vb6. To make it simple there a three text box on the Report. First for (Date), Second for (In-Time) and the third for (Out-Time). The data is being filled in the text box from SQL Database.
What i want is to put condition that if (In-Time) is greater than e.g. 07:30 then the time diplayed in the text box must be RED in color in the report. Likewise if the (In-Time) is less than 07:30 the text color should be Black color.

Thanks a Zillion!!!!!!!!!!!!!!!!!!!!!!!
Mar 25 '07 #1
14 20009
Dököll
2,364 Expert 2GB
Greetings, Irfi!

I hear your pain. I tried something with a textbox and it did not work for me either. I am going to take another shot at it in a moment. Someone will likely come up with a better solution. No worries. In the meantime, Here is a solution. You should consider adding labels to gather the time from the database whereby:

Your form code

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub SearchData_click()
  3.  
  4. ....your existing code goes here
  5.  
  6.     If Label1.Caption > 7:30 Then
  7.     Label_Value = "BLUE"                     
  8.     Label_BG.Change_It
  9.  
  10.     ElseIf Label1.Caption < 7:30 Then
  11.     Label_Value = "BLACK"                 
  12.     Label_BG.Change_It
  13.  
  14.     End If
  15.  
  16. End Sub
  17.  
  18.  
You may also need to make your label a diffrent colour since text usually comes in black


Now you need to build a module..

Module code

Expand|Select|Wrap|Line Numbers
  1.  
  2. Public Label_Value As String
  3.  
  4. Public Sub Change_IT()
  5.  
  6.     If UCase(Label_Value ) = "BLUE" Then               
  7.     Form1.Label1.BackColor = &HFF0000
  8.     ElseIf UCase(Label_Value ) = "BLACK" Then        
  9.     Form1.Label1.BackColor = &000000
  10.  
  11.     End If
  12. End Sub
  13.  
  14.  
Form1 is the name of the form that has the Labels, by the way, I am sure you already know this.

Good luck. Let us know if this does not work. Again someone may see something I am not seing:-)

Dököll
Mar 25 '07 #2
SammyB
807 Expert 512MB
Hi, Please anyone out there can help me!!!!!!!!!!!!
I am building a Data Report in vb6. To make it simple there a three text box on the Report. First for (Date), Second for (In-Time) and the third for (Out-Time). The data is being filled in the text box from SQL Database.
What i want is to put condition that if (In-Time) is greater than e.g. 07:30 then the time diplayed in the text box must be RED in color in the report. Likewise if the (In-Time) is less than 07:30 the text color should be Black color.

Thanks a Zillion!!!!!!!!!!!!!!!!!!!!!!!
You just need to check the time and set the ForeColor property of the TextBox. Something like this, except you will probably already have the time in a DateTime variable.
Expand|Select|Wrap|Line Numbers
  1.     Dim dt As Date
  2.     Dim dtMin As Date
  3.     dtMin = CDate("7:30")
  4.     dt = CDate(TextBox1.Text)
  5.     If (dt < dtMin) Then
  6.         TextBox1.ForeColor = vbRed
  7.     Else
  8.         TextBox1.ForeColor = vbBlack
  9.     End If
Mar 25 '07 #3
irfi
5
You just need to check the time and set the ForeColor property of the TextBox. Something like this, except you will probably already have the time in a DateTime variable.
Expand|Select|Wrap|Line Numbers
  1.     Dim dt As Date
  2.     Dim dtMin As Date
  3.     dtMin = CDate("7:30")
  4.     dt = CDate(TextBox1.Text)
  5.     If (dt < dtMin) Then
  6.         TextBox1.ForeColor = vbRed
  7.     Else
  8.         TextBox1.ForeColor = vbBlack
  9.     End If

Thanks SammyB,
But my problem is not in the form. How to add this property in data report.
Thanks
Mar 26 '07 #4
Dököll
2,364 Expert 2GB
Hi, Please anyone out there can help me!!!!!!!!!!!!
I am building a Data Report in vb6. To make it simple there a three text box on the Report. First for (Date), Second for (In-Time) and the third for (Out-Time). The data is being filled in the text box from SQL Database.
What i want is to put condition that if (In-Time) is greater than e.g. 07:30 then the time diplayed in the text box must be RED in color in the report. Likewise if the (In-Time) is less than 07:30 the text color should be Black color.

Thanks a Zillion!!!!!!!!!!!!!!!!!!!!!!!
OK, let me think a minute. What format do you want this report to come in? I am sure there's a number of ways to achieve this. Have you searched here for an answer?

I know a DataReport can come in without the help of Data Environment, I'd have to look to really tell you. DataReport also comes in MS Word format, no texboxes though, so no joy there. Can you tell us a little more?
Mar 27 '07 #5
pureenhanoi
175 100+
Thanks SammyB,
But my problem is not in the form. How to add this property in data report.
Thanks
I think this can help you:
Each DataReport have Secions (example: Report Header = Section4; you can see it when open report designer)
Each Section has an array called: Controls(). If you put a control in this section, it will be added in to Controls() array, and you can call-out this control by it's index. (the first control which you put will have index=0 and so on..).
So, to change its color, you need some codes like this:
rptData.Sections(1).Controls(1).BackColor = ...
or rptData.Sections(1).Controls(1).ForeColor = ...
Controls in DataReport have properties like in Forms, and you can use Caption Property or Text Property to make conditions
Good lucks
Mar 27 '07 #6
pureenhanoi
175 100+
Thanks SammyB,
But my problem is not in the form. How to add this property in data report.
Thanks
I think this can help you:
Each DataReport have Secions (example: Report Header = Section4; you can see it when open report designer)
Each Section has an array called: Controls(). If you put a control in this section, it will be added in to Controls() array, and you can call-out this control by it's index. (the first control which you put will have index=0 and so on..).
So, to change its color, you need some codes like this:
rptData.Sections(1).Controls(1).BackColor = ...
or rptData.Sections(1).Controls(1).ForeColor = ...
Controls in DataReport have properties like in Forms( and you can use Caption Property or Text Property to make conditions) . One diffrent thing that: you can't call it by name. You must call it by index, so, you should remember which you put in Sections first
Good lucks
Mar 27 '07 #7
Dököll
2,364 Expert 2GB
Are you hoping to bring an SQL database report to VB?
In other words, are you saying the textboxes are in fact on your database and of it and not VB?
Mar 28 '07 #8
irfi
5
Hi Dököll;
ok let me explain to you in detail.
First lets talk about my FORM. I am getting data from the SQL Database in my form. I have some text boxes and MSFlexGrid. I populate the MSFlexgrid and i have made a small function called ChangeFlexgridcolor. In my form evey thing is fine. If the time is less than 07:30 the text color in the MSFlexGrid remains black. And if more than 07:30 the text of the time in MSFlexGrid changes to RED. Now to print this MSFlexGrid i have used PrintForm method. But here the problem is that it does not print entire records from the MSFlexGrid.
So i decided to use DataReport with DataEnvironment. I can view the data in my Report from the SQL Database. The only problem i have is how to call the Changetextcolor function in the Report. The report is displayed correctly but the color does not change as it changes in the MSFlexGrid in my form. Morover i need to add a label in the report that displays the department name from the database at runtime.
Plz help me out!!!
Once agian THANKS for CONSIDERING my request and sparing your valuable time for me.
Take care and hope to hear from you soon!
irfi
Mar 29 '07 #9
irfi
5
Thanks pureenhanoi i will check and get back to you
Thanks again!!!
Mar 29 '07 #10
Dököll
2,364 Expert 2GB
Hi Dököll;
ok let me explain to you in detail.
First lets talk about my FORM. I am getting data from the SQL Database in my form. I have some text boxes and MSFlexGrid. I populate the MSFlexgrid and i have made a small function called ChangeFlexgridcolor. In my form evey thing is fine. If the time is less than 07:30 the text color in the MSFlexGrid remains black. And if more than 07:30 the text of the time in MSFlexGrid changes to RED. Now to print this MSFlexGrid i have used PrintForm method. But here the problem is that it does not print entire records from the MSFlexGrid.
So i decided to use DataReport with DataEnvironment. I can view the data in my Report from the SQL Database. The only problem i have is how to call the Changetextcolor function in the Report. The report is displayed correctly but the color does not change as it changes in the MSFlexGrid in my form. Morover i need to add a label in the report that displays the department name from the database at runtime.
Plz help me out!!!
Once agian THANKS for CONSIDERING my request and sparing your valuable time for me.
Take care and hope to hear from you soon!
irfi
With all honesty, I am no sure how this can be achieved through DataReport/Data Environmt. My way of doing this does not allow textboxes to be carried over. I attempted to fetch some things for you to no avail. I was able to find an example similar to my DataReport type. Have a look:

http://www.dreamincode.net/forums/showtopic13544.htm

Give above time to load, snapshots included. Continue asking questions, we'll ge there...
Apr 3 '07 #11
wahab
1
I have the same situation on different requirement. I want to display RptTextbox object dynamicaly with 2 differnt font setting based on the one of the row object value. Would like to know.. How to access/control each row object (ie RptTextbox) in Detail Section of the data report. i can access the Detail Section object like below...

Section("xys_detail").controls("name_rptTxtbox").v isible=false.

Here it is hiding all the rpttxtboxes, whereas, i want to hide few textboxes based on some condition. Additional to this query..

how to get the value/text of RptTextbox of DetailSection that bind with DataField.

thanks in advance.
May 11 '07 #12
Hi, Please anyone out there can help me!!!!!!!!!!!!
I am building a Data Report in vb6. To make it simple there a three text box on the Report. First for (Date), Second for (In-Time) and the third for (Out-Time). The data is being filled in the text box from SQL Database.
What i want is to put condition that if (In-Time) is greater than e.g. 07:30 then the time diplayed in the text box must be RED in color in the report. Likewise if the (In-Time) is less than 07:30 the text color should be Black color.

Thanks a Zillion!!!!!!!!!!!!!!!!!!!!!!!
  • Try to break 1 label to 2 label with different foreground color then place them at same position (overlay). You'd change your sql to seperate data to these labels like In-Time data to label1 and another to label2
  • This could make a lot of work to do but i've no any idea to find out that datareport can do a conditioning format.
  • This may help you = good luck for all
Feb 25 '08 #13
@AlninlA
I have been following this thread because i also wanted the answer for similar kind of problem. I tried a lot but i could not get the solution at last i created two field for two different conditions in the table and attached them to data report texboxes one another one by overlaping and set the desired properties and made one field empty when its condition is false ; hence which ever textbox is filled it shows its colour and other texbox will be hide automatically because it is empty.

i think you should also use this kind of technique because as per my experience we cannot change texbox properties for perticular records at runtime.

Thank you.
Jan 4 '14 #14
DataReport5.Sections("Section1").Controls.Item("co lumnname").ForeColor = rgbRed
Jan 16 '14 #15

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

Similar topics

1
by: Alex | last post by:
Hi all, I've seen this noted in many posts, but nothing I've checked out gives me any clue on how to do this. Basically as my topic says, I have a DTS and I simply need to export some data...
0
by: Dalan | last post by:
Perhaps someone has experienced this problem. I developed an Access 97 Runtime database on a Windows 98 SE machine. I have three reports that can be optionally copied to a floppy disk or hard drive...
9
by: Colin McGuire | last post by:
Hi, I have an report in Microsoft Access and it displays everything in the table. One column called "DECISION" in the table has either 1,2, or 3 in it. On my report it displays 1, 2, or 3. I want...
6
by: Mike Conklin | last post by:
This one really has me going. Probably something silly. I'm using dcount for a report to determine the number of different types of tests proctored in a semester. My report is based on a...
6
by: thomas.jacobs | last post by:
I have reports formated and now need to use that format on another table name with the same field names as formated in the report. I belive it is in the properties but I can't seem to find it....
3
by: Thad | last post by:
I'm new to C# and I was trying to create a Crystal Report. I've designed a simple report and I've used several methods for attaching fields to the report at design time. I've used a DataSet that...
3
by: Diggler | last post by:
I was working on a report that is populated with three different tables in a strongly-typed dataset. The tables are populated from custom objects rather than directly from SQL Server. I loop...
7
by: steve | last post by:
Hi All I need to change text in a Report Viewer document at runtime It is just the heading I want to change to match what the user has chosen as the Report to view How do I access the...
1
by: jessicahagg | last post by:
Hi, Goal: Change report body background color to white at runtime before exporting to pfd format. I am reproducing a web report useing .Net reportviewer -- The report is to have the same...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shćllîpôpď 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.