label refresh

E

Eddie

(novice)

Using a label to show a text message for the value of an option group. The
values renge from 1-4. Each value has its own message. When I open a new
record the label does not refresh to default value. (option block does)

Private Sub Optionblock_AfterUpdate()
Select Case Me![Optionblock]
Case Is = 1
Me![OptStatus].Caption = "Status1"
Me![OptStatus].FontSize = 28
Case Is = 2
Me![OptStatus].Caption = "Status2"
Me![OptStatus].FontSize = 28
Case Is = 3
Me![OptStatus].Caption = "Status3"
Me![OptStatus].FontSize = 28
Case Is = 4
Me![OptStatus].Caption = "Status4"
Me![OptStatus].FontSize = 18

End Select

Select Case Me![Optionblock]
Case Is = 1
Me![My_Label].].Caption = "Message1"
Me![My_Label].].FontSize = 18
Case Is = 2
Me![My_Label].].Caption = "message2"
Me![My_Label].].FontSize = 18
Case Is = 3
Me![My_Label].Caption = "Message3"
Me![My_Label].].FontSize = 18
Case Is = 4
Me![My_Label].].Caption = "Message4"
Me![My_Label].FontSize = 18

End Select
Refresh
End Sub


Any suggestion?
 
S

Steve Schapel

Eddie,

First of all, the code is a bit more complicated than necessary,
especially running 2 cycles of the Select Case. Here is a suggestion:

Private Sub Optionblock_AfterUpdate()
Me![OptStatus].FontSize = 28
Me![My_Label].].FontSize = 18
Select Case Me![Optionblock]
Case 1
Me![OptStatus].Caption = "Status1"
Me![My_Label].].Caption = "Message1"
Case 2
Me![OptStatus].Caption = "Status2"
Me![My_Label].].Caption = "Message2"
Case 3
Me![OptStatus].Caption = "Status3"
Me![My_Label].].Caption = "Message3"
Case 4
Me![OptStatus].Caption = "Status4"
Me![OptStatus].FontSize = 18
Me![My_Label].].Caption = "Message4"
End Select
End Sub

Now, it may be that you need to run thisd code on the Current event of
the form itself, as well as the After Update event of the option group.
The option group's After Update event does not occur when you move to
another record.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top