Connecting Tech Pros Worldwide Forums | Help | Site Map

FontBold property value gets lost when Forecolor changes?

Pieter Linden
Guest
 
Posts: n/a
#1: Nov 12 '05
Hi,
Hopefully it's just me missing something obvious (but at 2AM, not much
is obvious, I guess...) I have a table of courses that people have
taken (StudentID,CourseID) and the user selects a student from a
combobox on the form, and it highlights courses in the student's
specialization (that's fine). But when I run the code to change the
font's ForeColor property, the FontBold property mysteriously gets
lost. Is my code just screwy or what? I tried storing the value of
ctl.FontBold into blnWasBold (because I couldn't figure out what was
goingo on), but I can't get it to work. Any ideas? The fact that the
Forecolor of the button changes should not affect the FontBold
property of the same button, should it?

Option Compare Database
Option Explicit

Private Sub cboStudent_AfterUpdate()
'This Code Works.... =)
' open the rs of required courses for that field. Make them bold.
Dim db As DAO.database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim ctl As Control
'Dim blnWasBold As Boolean <---the .FontBold property is getting
lost for some reason... why?

Call ResetCommandButtons
strSQL = "SELECT CoursesTaken.CourseNo FROM CoursesTaken WHERE
CoursesTaken.StudentID =" & Me.cboStudent.Column(0)

Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
If rs.RecordCount > 0 Then
Do Until rs.EOF
For Each ctl In Me.Controls
If ctl.Name = "cmd" & rs.Fields("CourseNo") Then
'blnWasBold = ctl.FontBold
ctl.ForeColor = vbBlue
'ctl.FontBold = blnWasBold

End If
Next ctl
rs.MoveNext
Loop
End If

rs.Close
Set rs = Nothing
Set db = Nothing
End Sub

Could someone please clue me in as to how to do this right?
Plan: all courses for the chosen specialization are bolded.
When user chooses a Student, the ForeColor of all the buttons for all
the courses the student has taken changes to blue....

I'm getting the vbBlue just fine... but I lose the bold.
Any ideas?

Thanks!
Pieter

Phil Stanton
Guest
 
Posts: n/a
#2: Nov 12 '05

re: FontBold property value gets lost when Forecolor changes?


Isn't it FonrWeight = 800

Phil
"Pieter Linden" <pietlinden@hotmail.com> wrote in message
news:bf31e41b.0311182302.13fc6db5@posting.google.c om...[color=blue]
> Hi,
> Hopefully it's just me missing something obvious (but at 2AM, not much
> is obvious, I guess...) I have a table of courses that people have
> taken (StudentID,CourseID) and the user selects a student from a
> combobox on the form, and it highlights courses in the student's
> specialization (that's fine). But when I run the code to change the
> font's ForeColor property, the FontBold property mysteriously gets
> lost. Is my code just screwy or what? I tried storing the value of
> ctl.FontBold into blnWasBold (because I couldn't figure out what was
> goingo on), but I can't get it to work. Any ideas? The fact that the
> Forecolor of the button changes should not affect the FontBold
> property of the same button, should it?
>
> Option Compare Database
> Option Explicit
>
> Private Sub cboStudent_AfterUpdate()
> 'This Code Works.... =)
> ' open the rs of required courses for that field. Make them bold.
> Dim db As DAO.database
> Dim rs As DAO.Recordset
> Dim strSQL As String
> Dim ctl As Control
> 'Dim blnWasBold As Boolean <---the .FontBold property is getting
> lost for some reason... why?
>
> Call ResetCommandButtons
> strSQL = "SELECT CoursesTaken.CourseNo FROM CoursesTaken WHERE
> CoursesTaken.StudentID =" & Me.cboStudent.Column(0)
>
> Set db = CurrentDb
> Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
> If rs.RecordCount > 0 Then
> Do Until rs.EOF
> For Each ctl In Me.Controls
> If ctl.Name = "cmd" & rs.Fields("CourseNo") Then
> 'blnWasBold = ctl.FontBold
> ctl.ForeColor = vbBlue
> 'ctl.FontBold = blnWasBold
>
> End If
> Next ctl
> rs.MoveNext
> Loop
> End If
>
> rs.Close
> Set rs = Nothing
> Set db = Nothing
> End Sub
>
> Could someone please clue me in as to how to do this right?
> Plan: all courses for the chosen specialization are bolded.
> When user chooses a Student, the ForeColor of all the buttons for all
> the courses the student has taken changes to blue....
>
> I'm getting the vbBlue just fine... but I lose the bold.
> Any ideas?
>
> Thanks!
> Pieter[/color]


Phil Stanton
Guest
 
Posts: n/a
#3: Nov 12 '05

re: FontBold property value gets lost when Forecolor changes?


Or even FontWeight = 800

Phil
"Phil Stanton" <phil@stantonfamily.co.uk> wrote in message
news:3fbc052e$0$64734$65c69314@mercury.nildram.net ...[color=blue]
> Isn't it FonrWeight = 800
>
> Phil
> "Pieter Linden" <pietlinden@hotmail.com> wrote in message
> news:bf31e41b.0311182302.13fc6db5@posting.google.c om...[color=green]
> > Hi,
> > Hopefully it's just me missing something obvious (but at 2AM, not much
> > is obvious, I guess...) I have a table of courses that people have
> > taken (StudentID,CourseID) and the user selects a student from a
> > combobox on the form, and it highlights courses in the student's
> > specialization (that's fine). But when I run the code to change the
> > font's ForeColor property, the FontBold property mysteriously gets
> > lost. Is my code just screwy or what? I tried storing the value of
> > ctl.FontBold into blnWasBold (because I couldn't figure out what was
> > goingo on), but I can't get it to work. Any ideas? The fact that the
> > Forecolor of the button changes should not affect the FontBold
> > property of the same button, should it?
> >
> > Option Compare Database
> > Option Explicit
> >
> > Private Sub cboStudent_AfterUpdate()
> > 'This Code Works.... =)
> > ' open the rs of required courses for that field. Make them bold.
> > Dim db As DAO.database
> > Dim rs As DAO.Recordset
> > Dim strSQL As String
> > Dim ctl As Control
> > 'Dim blnWasBold As Boolean <---the .FontBold property is getting
> > lost for some reason... why?
> >
> > Call ResetCommandButtons
> > strSQL = "SELECT CoursesTaken.CourseNo FROM CoursesTaken WHERE
> > CoursesTaken.StudentID =" & Me.cboStudent.Column(0)
> >
> > Set db = CurrentDb
> > Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
> > If rs.RecordCount > 0 Then
> > Do Until rs.EOF
> > For Each ctl In Me.Controls
> > If ctl.Name = "cmd" & rs.Fields("CourseNo") Then
> > 'blnWasBold = ctl.FontBold
> > ctl.ForeColor = vbBlue
> > 'ctl.FontBold = blnWasBold
> >
> > End If
> > Next ctl
> > rs.MoveNext
> > Loop
> > End If
> >
> > rs.Close
> > Set rs = Nothing
> > Set db = Nothing
> > End Sub
> >
> > Could someone please clue me in as to how to do this right?
> > Plan: all courses for the chosen specialization are bolded.
> > When user chooses a Student, the ForeColor of all the buttons for all
> > the courses the student has taken changes to blue....
> >
> > I'm getting the vbBlue just fine... but I lose the bold.
> > Any ideas?
> >
> > Thanks!
> > Pieter[/color]
>
>[/color]


Pieter Linden
Guest
 
Posts: n/a
#4: Nov 12 '05

re: FontBold property value gets lost when Forecolor changes?


"Phil Stanton" <phil@stantonfamily.co.uk> wrote in message news:<3fbc8db1$0$64734$65c69314@mercury.nildram.ne t>...[color=blue]
> Or even FontWeight = 800
>
> Phil
> "Phil Stanton" <phil@stantonfamily.co.uk> wrote in message
> news:3fbc052e$0$64734$65c69314@mercury.nildram.net ...[color=green]
> > Isn't it FonrWeight = 800
> >
> > Phil[/color][/color]

Phil,
what I don't get is that the setting stuff bold works fine. It's when
I change the colors that the bold property gets lost. I thought the
two properties were independent... Not true?
Phil Stanton
Guest
 
Posts: n/a
#5: Nov 12 '05

re: FontBold property value gets lost when Forecolor changes?


Pieter

My understanding is that the property you need is called FontWeight, not
FontBold . I am using AK2, but possibly in the later version of Access there
may be a FontBold property. Further than that I can offer no help

Phil
"Pieter Linden" <pietlinden@hotmail.com> wrote in message
news:bf31e41b.0311200802.5a8f00ab@posting.google.c om...[color=blue]
> "Phil Stanton" <phil@stantonfamily.co.uk> wrote in message[/color]
news:<3fbc8db1$0$64734$65c69314@mercury.nildram.ne t>...[color=blue][color=green]
> > Or even FontWeight = 800
> >
> > Phil
> > "Phil Stanton" <phil@stantonfamily.co.uk> wrote in message
> > news:3fbc052e$0$64734$65c69314@mercury.nildram.net ...[color=darkred]
> > > Isn't it FonrWeight = 800
> > >
> > > Phil[/color][/color]
>
> Phil,
> what I don't get is that the setting stuff bold works fine. It's when
> I change the colors that the bold property gets lost. I thought the
> two properties were independent... Not true?[/color]


Closed Thread