| 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] |