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. -
Public Sub PutInData()
-
On Error GoTo Err_PutIndata
-
Dim sql As String
-
Dim f As Form
-
Dim db As DAO.Database
-
Dim rs As DAO.Recordset
-
Dim rsHoliday As DAO.Recordset
-
Dim sqlHoliday As String
-
Dim MyDate As Date
-
Dim i As Integer
-
Dim strShiftDetails As String
-
-
Set f = Forms!frmCalendar
-
-
For i = 1 To 37
-
f("text" & i) = Null
-
Next i
-
-
sql = "SELECT * FROM [qryShifts] WHERE ((MONTH(ShiftDetailDate) = " & _
-
f!month & " AND YEAR(ShiftDetailDate) = " & f!year & ")) " & _
-
"ORDER BY tblShiftDetail.ShiftDetailDate, tblEmployee.EmployeeFirstName;"
-
sqlHoliday = "SELECT * FROM [tblHoliday] WHERE ((MONTH(ShiftDetailDate) = " & _
-
f!month & " AND YEAR(ShiftDetailDate) = " & f!year & ")) " & _
-
"ORDER BY [tblHoliday].[ShiftDetailDate];"
-
-
Set db = CurrentDb()
-
Set rs = db.OpenRecordset(sql)
-
Set rsHoliday = db.OpenRecordset(sqlHoliday)
-
-
If rs.RecordCount > 0 Then
-
For i = 1 To 37
-
If IsDate(f("date" & i)) Then
-
MyDate = Format((f("date" & i)), "mm/dd/yyyy")
-
Do While Not rs.EOF
-
If rs![ShiftDetailDate] = MyDate Then
-
If rs![ShiftDetailOnCall] = True Then
-
strShiftDetails = strShiftDetails & Left(rs!EmployeeFirstName, 1) & Left(rs!EmployeeLastName, 1) & " " & _
-
rs!ShiftStartTime & "-" & rs!ShiftEndTime & " On Call" & vbCrLf
-
Else
-
strShiftDetails = strShiftDetails & Left(rs!EmployeeFirstName, 1) & Left(rs!EmployeeLastName, 1) & " " & _
-
rs!ShiftStartTime & "-" & rs!ShiftEndTime & vbCrLf
-
End If
-
End If
-
rs.MoveNext
-
Loop
-
If Len(strShiftDetails) > 0 Then
-
f("text" & i) = Left$(strShiftDetails, Len(strShiftDetails) - 2) 'Strip vbCrLf
-
End If
-
strShiftDetails = "" 'Reset
-
rs.MoveFirst
-
rsHoliday.FindFirst "ShiftDetailDate = #" & MyDate & "#"
-
If Not rsHoliday.NoMatch Then
-
strShiftDetails = rsHoliday![Description] & " - Help Desk Off!!"
-
f("text" & i) = strShiftDetails
-
strShiftDetails = ""
-
End If
-
End If
-
Next i
-
End If
-
-
rsHoliday.Close
-
Set rsHoliday = Nothing
-
rs.Close
-
Set rs = Nothing
-
Set db = Nothing
-
-
Exit_PutIndata:
-
Exit Sub
-
-
Err_PutIndata:
-
MsgBox Err.Description, vbExclamation, "Error in PutIndata()"
-
Resume Exit_PutIndata
-
End Sub
-
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
2 7913
"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)>
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: -
If rs![ShiftDetailOnCall] = True Then
-
'(C) - at end of String indicates On Call Status
-
strShiftDetails = strShiftDetails & Left(rs!EmployeeFirstName, 1) & Left(rs!EmployeeLastName, 1) & " " & _
-
rs!ShiftStartTime & "-" & rs!ShiftEndTime & " (C)" & vbCrLf
-
Else
-
strShiftDetails = strShiftDetails & Left(rs!EmployeeFirstName, 1) & Left(rs!EmployeeLastName, 1) & " " & _
-
rs!ShiftStartTime & "-" & rs!ShiftEndTime & vbCrLf
-
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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?...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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)...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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....
|
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...
| |