Stupid .label.caption not repainting

Dragos

New Member
Joined
Jun 13, 2011
Messages
5
It seems stupid and I never had this problem before (Delphi, VB).

Using Access 2007 and trying to change a label's Caption at runtime (OnCurrent event of a form). I did DoEvents, I did Me.Repaint, but the **** label displays the same caption.

(the same is True with a command button, it changes is Caption only when I click on it)

Still, the form goes in AllowEdits and AllowDeletitions.

It behaves like an event is not raised.

Here's te code...

Private Sub Form_Current()
' other stuff
If GetUserRights(Me![sAreaCode]) = False Then
Me.AllowDeletions = False
Me.AllowEdits = False
Me.lblTitle.Caption = "Location - R/O"
Else
Me.AllowDeletions = True
Me.AllowEdits = True
Me.lblTitle.Caption = "Location - R/W"
End If
Me.Repaint
DoEvents
End Sub
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
I have acc2003. I mocked up a sample based on your code.
I set a global variable HoldValue and populate it when Form loads.

In your text0, I put the value of [Exec id], a field from a table with 9 records.
In the On Current, I checked to see if the current [Exec Id] is the NOT same as the HoldValue. If NOT the same I show R/O, if same I show R/W.

Everything seems to work as expected.
I commented the Me.Repaint - I don't think it's necessary.

Code:
Private Sub Form_Current()
' other stuff
'If GetUserRights(Me![sAreaCode]) = False Then
Me.Text0 = Me.[Exec id]
If HoldValue <> Me.[Exec id] Then
    Me.AllowDeletions = False
    Me.AllowEdits = False
    Me.lblTitle.Caption = "Location - R/O"
Else
    Me.AllowDeletions = True
    Me.AllowEdits = True
    Me.lblTitle.Caption = "Location - R/W"
End If
HoldValue = Nz(Me.[Exec id], "999") ' after 9 records [exec id] is empty, so signify with 999
Debug.Print "Print execId " & Me.[Exec id] & "   Holdvalue  " & HoldValue
'Me.Repaint
DoEvents
End Sub

Private Sub Form_Open(Cancel As Integer)
HoldValue = Me.[Exec id]
End Sub

Here are my debug.print values
Code:
Print execId 1   Holdvalue  1
Print execId 1   Holdvalue  1
Print execId 1   Holdvalue  1
Print execId 2   Holdvalue  2
Print execId 2   Holdvalue  2
Print execId 2   Holdvalue  2
Print execId 3   Holdvalue  3
Print execId 3   Holdvalue  3
Print execId 5   Holdvalue  5
Print execId    Holdvalue  999
 
Upvote 0
Thanks jackd. I still don't get it. I'm in 2007 and I have a Split Form and a Detail Section on the same form. If I navigate thru Navigation Buttons the label is uptated as it should be, but if I'm clicking on different records in the Split Section of the form, it seems that Microsoft forgot to fire up some event (the one that really repaints the controls that changed). All other stuff (there's more than extracted here as sample) that I wrote to happen are happening in the Form_Current(), except repainting the **** label.

Thanks anyway :).
 
Upvote 0

Forum statistics

Threads
1,224,504
Messages
6,179,142
Members
452,892
Latest member
JUSTOUTOFMYREACH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top