Switchboard - Text Color

schumarg

Registered User.
Local time
Today, 10:42
Joined
May 13, 2003
Messages
94
Hi,

Been searching, but did not find a reference for the following. I'm using Access2002, but shouldn't matter.

My switchboard has a list of items, two of which appears on multiple screens. One is "Return to Main Menu" and "Exit Application". What I would like to do is have these two items appears with Blue and Red text color. Blue for Return and Red for Exit.

I've been trying the OnCurrent event on the form load with an if statment, but can not figure out the code.

Not sure this is possible, but am assuming it is. Any help would be greatly appreciated.



Thanks,
Bob
 
I am assuming that the switchboard was generated by access itself?

If that is the case then i know that in access 97 it can be done.
Not sure if is the best way but...
In the switchboard form there is some code that says fill options.
Scroll down that till you find the bit that puts the labels in. Should be something like
Private Sub FillOptions()
' Fill in the options for this switchboard page.

' The number of buttons on the form.
Const conNumButtons = 8

Dim dbs As Database
Dim rst As Recordset
Dim strSQL As String
Dim intOption As Integer

' Set the focus to the first button on the form,
' and then hide all of the buttons on the form
' but the first. You can't hide the field with the focus.
Me![Option1].SetFocus
For intOption = 2 To conNumButtons
Me("Option" & intOption).Visible = False
Me("OptionLabel" & intOption).Visible = False
Next intOption

' Open the table of Switchboard Items, and find
' the first item for this Switchboard Page.
Set dbs = CurrentDb()
strSQL = "SELECT * FROM [Switchboard Items]"
strSQL = strSQL & " WHERE [ItemNumber] > 0 AND [SwitchboardID]=" & Me![SwitchboardID]
strSQL = strSQL & " ORDER BY [ItemNumber];"
Set rst = dbs.OpenRecordset(strSQL)

' If there are no options for this Switchboard Page,
' display a message. Otherwise, fill the page with the items.
If (rst.EOF) Then
Me![OptionLabel1].Caption = "There are no items for this switchboard page"
Else
While (Not (rst.EOF))
Me("Option" & rst![ItemNumber]).Visible = True
Me("OptionLabel" & rst![ItemNumber]).Visible = True
Me("OptionLabel" & rst![ItemNumber]).Caption = rst![ItemText]



rst.MoveNext
Wend
End If

' Close the recordset and the database.
rst.Close
dbs.Close


place the piece of code below in the bit hust before the rst.MoveNext.


If Me("OptionLabel" & rst![ItemNumber]).Caption = "Return to Main Menu" Then
Me("OptionLabel" & rst![ItemNumber]).ForeColor = vbBlue
End If
If Me("OptionLabel" & rst![ItemNumber]).Caption = "Exit Application" Then
Me("OptionLabel" & rst![ItemNumber]).ForeColor = vbRed
End If



As i say it is a bit of a fiddle so there may be a better way of doing this and i have not tested it in anything other that access 97 so good luck.
Hope it helps

Steve
 
Hi,

Thanks, working, to an extent. Seems that when moving to a new switchboard, the colors remain for that position. Giving multiple Blues and Reds in the text.

Maybe something in a refresh or something.

Bob

ps: god I luv this site!!
 
yeah sorry. You will need to put in and else statement with those if's to set it back

Only tested it on a single board.
 
Hi,

Don't mean to be a pest, but......

Semi experienced user here, and I could probably get this in a few days, but Boss needs it by this evening. So.....if you have some free time....

If I'm being pushy, please tell me.

Bob
 
Bob

If Me("OptionLabel" & rst![ItemNumber]).Caption = "Return to Main Menu" Then
Me("OptionLabel" & rst![ItemNumber]).ForeColor = vbBlue
else
Me("OptionLabel" & rst![ItemNumber]).ForeColor =vbBlack
End If

Do the same for the other 1. That should do it

Steve
 
Steve,

Thanks!! Works perfectly!! And it does make that little bit of difference to set it off properly.

I was getting close, but sometimes my "close" is measured in days.

Bob
 

Users who are viewing this thread

Back
Top Bottom