473,320 Members | 2,177 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.

Change Font color of text string.

78
Hello All,

I have a DB that shows information generated on a form setup to look like a calendar. I am working with Windows 2000 and Access 2000.

Expand|Select|Wrap|Line Numbers
  1. Public Sub PutInData()
  2. On Error GoTo Err_PutIndata
  3. Dim sql As String
  4. Dim f As Form
  5. Dim db As DAO.Database
  6. Dim rs As DAO.Recordset
  7. Dim rsHoliday As DAO.Recordset
  8. Dim sqlHoliday As String
  9. Dim MyDate As Date
  10. Dim i As Integer
  11. Dim strShiftDetails As String
  12.  
  13. Set f = Forms!frmCalendar
  14.  
  15. For i = 1 To 37
  16.   f("text" & i) = Null
  17. Next i
  18.  
  19. sql = "SELECT * FROM [qryShifts] WHERE ((MONTH(ShiftDetailDate) = " & _
  20.        f!month & " AND YEAR(ShiftDetailDate) = " & f!year & ")) " & _
  21.        "ORDER BY tblShiftDetail.ShiftDetailDate, tblEmployee.EmployeeFirstName;"
  22. sqlHoliday = "SELECT * FROM [tblHoliday] WHERE ((MONTH(ShiftDetailDate) = " & _
  23.               f!month & " AND YEAR(ShiftDetailDate) = " & f!year & ")) " & _
  24.               "ORDER BY [tblHoliday].[ShiftDetailDate];"
  25.  
  26. Set db = CurrentDb()
  27. Set rs = db.OpenRecordset(sql)
  28. Set rsHoliday = db.OpenRecordset(sqlHoliday)
  29.  
  30. If rs.RecordCount > 0 Then
  31.   For i = 1 To 37
  32.     If IsDate(f("date" & i)) Then
  33.     MyDate = Format((f("date" & i)), "mm/dd/yyyy")
  34.       Do While Not rs.EOF
  35.         If rs![ShiftDetailDate] = MyDate Then
  36.             If rs![ShiftDetailOnCall] = True Then
  37.                 strShiftDetails = strShiftDetails & Left(rs!EmployeeFirstName, 1) & Left(rs!EmployeeLastName, 1) & " " & _
  38.                                     rs!ShiftStartTime & "-" & rs!ShiftEndTime & " On Call" & vbCrLf
  39.             Else
  40.                 strShiftDetails = strShiftDetails & Left(rs!EmployeeFirstName, 1) & Left(rs!EmployeeLastName, 1) & " " & _
  41.                                     rs!ShiftStartTime & "-" & rs!ShiftEndTime & vbCrLf
  42.             End If
  43.         End If
  44.         rs.MoveNext
  45.       Loop
  46.       If Len(strShiftDetails) > 0 Then
  47.         f("text" & i) = Left$(strShiftDetails, Len(strShiftDetails) - 2)      'Strip vbCrLf
  48.       End If
  49.       strShiftDetails = ""      'Reset
  50.       rs.MoveFirst
  51.       rsHoliday.FindFirst "ShiftDetailDate = #" & MyDate & "#"
  52.         If Not rsHoliday.NoMatch Then
  53.           strShiftDetails = rsHoliday![Description] & " - Help Desk Off!!"
  54.           f("text" & i) = strShiftDetails
  55.           strShiftDetails = ""
  56.         End If
  57.     End If
  58.   Next i
  59. End If
  60.  
  61. rsHoliday.Close
  62. Set rsHoliday = Nothing
  63. rs.Close
  64. Set rs = Nothing
  65. Set db = Nothing
  66.  
  67. Exit_PutIndata:
  68.   Exit Sub
  69.  
  70. Err_PutIndata:
  71.   MsgBox Err.Description, vbExclamation, "Error in PutIndata()"
  72.   Resume Exit_PutIndata
  73. End Sub
  74.  
What I want to do is if [shiftdetailoncall] = True then change the font color to RED for information stored (Rather then putting On Call text in place). However I need to have the rest of the text left Black.

Note: It does not have to be a color change, but I need someway to visually set it appart from the rest.

Information is being viewed in a textbox on the form, then opened in a report.

Can anyone help with achieving this? I am at a complete loss. Can this even be done?

Thank you in advance for any advice on this.

Nick
May 9 '08 #1
2 7913
missinglinq
3,532 Expert 2GB
"What I want to do is if [shiftdetailoncall] = True then change the font color to RED for information stored"

I'm not at all sure what you mean by this. Formatting is never done for information stored but rather forinformation displayed!And your code is way too complex for me to understand remotely.

Any formatting will have to done thru your form. If the form is datasheet or continuous the formatting will have to be done thru Conditional Formatting from the menu, otherwise it may also be done thru code in the Form's OnCurrent event.

Linq ;0)>
May 9 '08 #2
ADezii
8,834 Expert 8TB
Nick, if I interpret your request correctly, this cannot be done. Your request would entail different formatting (ForeColor, Underline, Italic, etc.) for individual lines in a Standard Text Box Control, depending on whether or not the [ShiftDetailOnCall] Field was True. To the best of my knowledge, this cannot be done in a Standard Text Box Control. You can, however, specify unique Text within the strShiftDetails Variable to indicate this condition. This is, however, what you basically have already:
Expand|Select|Wrap|Line Numbers
  1. If rs![ShiftDetailOnCall] = True Then
  2.   '(C) - at end of String indicates On Call Status
  3.   strShiftDetails = strShiftDetails & Left(rs!EmployeeFirstName, 1) & Left(rs!EmployeeLastName, 1) & " " & _
  4.                                     rs!ShiftStartTime & "-" & rs!ShiftEndTime & " (C)" & vbCrLf
  5. Else
  6.   strShiftDetails = strShiftDetails & Left(rs!EmployeeFirstName, 1) & Left(rs!EmployeeLastName, 1) & " " & _
  7.                                     rs!ShiftStartTime & "-" & rs!ShiftEndTime & vbCrLf
  8. End If
NOTE: If there was only a Single Shift per day, this could be done since the Formatting would apply to the entire Control.
May 9 '08 #3

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

Similar topics

4
by: Ronny Sigo | last post by:
Hello all, I am trying to programmatically change the orientation of a MS Word Document to landscape. I must be doing something wrong cause it does not work ... can anybody help me with this?...
2
by: Susan Sullivan | last post by:
How can I change properties of a child form through a parent form? I have a child form with a rich text box. I want to control font properties of the rich text box through a menu on the parent...
3
by: Jim in Arizona | last post by:
I have a gridview that's being populated from an access db query. The problem I'm having is that the date/time fields in access that are populating the gridview are showing both date and time, when...
0
by: the.tinapatel | last post by:
Guys, I want the user to be able to select font (such as Bold, Italic, underline) and stuff like that from a dropdown list) and then I wanna apply these properties to all my page (all text). Now...
1
by: dhaneshrs | last post by:
I have a small code that shows inactive and active users from the ms access DB. <%@ Page Language="VB" MasterPageFile="~/MasterPageAdmin.master" Title="Welcome" %> <%@ Import...
7
by: =?Utf-8?B?QnJpYW4gQ29vaw==?= | last post by:
I want to change the font color and weight at a specific position in the text. I am not sure where or what I need to do. It will be at position 155/156 from the left on each line. Here is the...
4
by: =?Utf-8?B?Um9nZWxpbw==?= | last post by:
hey, I want to draw one thing, then dynamically change fonts to a different font in the same string. can I do that?? any help ?? it needs to be using "Graphics.Drawstring" method myactual...
3
by: CSharper | last post by:
Is it possible to selectivly change the color of an item in text. I saw ForeColor option, but it changes the color of all the items. If it is not possible, is there any other control list listbox...
6
by: gavy7210 | last post by:
hello i am using struts 1.2,Eclipse Platform Version: 3.4.2,mySql 5.0.1,jdk 1.5.. i have a login form(jsp) in which a user logs in,in case he doesnt enter his username and/or password an error...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
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)...
0
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...
0
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.